ChilKat Segmentation Fault in Linux Daemon

Linux specific forum
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

ChilKat Segmentation Fault in Linux Daemon

Post by swhite »

Hi

I am using the Chilkat library for email and it works perfectly if I run my application purely as a console application, however, when I run the same application as a Linux Daemon I get a segmentation fault on the line below.

CkMailMan::ckCreate()

I am assuming that something about the forking process loses access to the chilkat library but I have no idea what needs to be changed to enable it to work. Does anyone have a suggestion about steps to try?

Thanks,
Simon
Simon White
dCipher Computing
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Re: ChilKat Segmentation Fault in Linux Daemon

Post by swhite »

Hi

It appears the problem is even stranger. If I run the code below with my valid unlock code it works fine if I use the "Compile with Debugger" option and I get all the expected log entries. However if I create a console application and run it from the Dolphin File Manager I only get "ChilKatTest ckCreate()" in the log and the console app terminates as soon as CkFtp2::ckCreate() is called.

Code: Select all

XIncludeFile "CkFtp2.pb"
Global goBj.i

Procedure ErrorHandler()
   WriteStringN(1,"Error "+Str(ErrorCode())+" "+ErrorMessage()+" occurred on line "+Str(ErrorLine())+" at address "+Str(ErrorAddress()))
EndProcedure

OnErrorCall(@ErrorHandler())

If OpenFile(1,"chilkattest.log",#PB_File_SharedRead | #PB_File_SharedWrite | #PB_File_Append| #PB_Ascii)
   WriteStringN(1,"ChilKatTest ckCreate()")
   FlushFileBuffers(1)
   
   goBj = CkFtp2::ckCreate()
   
   WriteStringN(1,"ChilKatTest ckUnlockComponent()")
   FlushFileBuffers(1)
   
   Debug CkFtp2::ckUnlockComponent(goBj,"**myunlockcode**")
   
   WriteStringN(1,"ChilKatTest Running")
   FlushFileBuffers(1)
   Define lnSec.i = ElapsedMilliseconds()
   Repeat
      Delay(100)
      WriteStringN(1,"ChilKatTest "+Str(ElapsedMilliseconds()))
      FlushFileBuffers(1)
  Until ElapsedMilliseconds() - lnSec > 2000
   
   WriteStringN(1,"ChilKatTest Stop")
   FlushFileBuffers(1)
   
   CkFtp2::ckDispose(goBj)
   CloseFile(1)
EndIf

Simon White
dCipher Computing
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Solved: ChilKat Segmentation Fault in Linux Daemon

Post by swhite »

Hi

I found the problem with the Chilkat Library. They use the following to open their shared objects:

Code: Select all

 CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPb-9_5_0.so")
which works just fine from the Purebasic IDE but does not work from a Linux Terminal or from a Linux File Manager. The code should be:

Code: Select all

CkGlobalLibId.i = OpenLibrary(#PB_Any, "./libchilkatPb-9_5_0.so")
The addition of the "./" fixed the problem. Now CkGlobalLibId is a non-zero value from the PB IDE, Linux Terminal or Linux File Manager.
Simon White
dCipher Computing
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Solved: ChilKat Segmentation Fault in Linux Daemon

Post by dibor »

swhite wrote: Thu Sep 06, 2018 3:55 pm The addition of the "./" fixed the problem.
Thank you very MUCH.
Have screwed up my head, and pull out all hair.

Now application is WORKS as should. :)
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Post Reply