Page 1 of 1

ChilKat Segmentation Fault in Linux Daemon

Posted: Mon Sep 03, 2018 8:57 pm
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

Re: ChilKat Segmentation Fault in Linux Daemon

Posted: Tue Sep 04, 2018 10:23 pm
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


Solved: ChilKat Segmentation Fault in Linux Daemon

Posted: Thu Sep 06, 2018 3:55 pm
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.

Re: Solved: ChilKat Segmentation Fault in Linux Daemon

Posted: Thu Dec 16, 2021 12:12 pm
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. :)