[fpc-devel] FPC shared lib called from C shared lib called from C main program crashes
Lukas Zeller
luz_info at synthesis.ch
Thu Sep 17 11:33:57 CEST 2009
Hello,
I already dug through the archives but found nothing really related to
a weird problem I have with a FPC shared lib which is used by a C
shared lib which in turn is a plugin to a C main program.
The net effect is that the FPC library crashes (apparently when trying
to allocate a FPC object) when just used as-is, but works wonderfully
if I put a Write(' ') into the FPC library's begin end.
I'm not familiar with FPC runtime internals, so I can only guess that
this Write (a WriteLn works as well, as long as it goes to stdout)
triggers some initialisation code of the FPC runtime that is otherwise
not called. I tried calling System.SysInitStdIO instead, hoping it
would maybe initialize the same thing a Write() does, but it did not
work, as other blind flight attempts to find a better fix than this
Write() didn't either.
I guess I really need to understand how the FPC runtime expects to be
initialized when located in a shared lib, but I couln't find any hint
so far in the FPC docs nor in the list archives.
The FPC shared library is implicitly loaded as a dependency of the C
shared lib plugin, which in turn is loaded by dlopen() from the C main
program. I run the program on Mac OS X and Linux (but not on Windows).
I can modify the C shared lib plugin and the FPC shared lib, but not
the main program (so it's out of question to have the FPC runtime
linked into the main program).
I'd really be glad if someone has any pointers or ideas how to
correctly fix this problem. I do understand shared lib technical
details and problems in general, but am a FPC newbie and have no idea
what the specifics regarding the FPC runtime might be.
Thanks for any help in advance!
Lukas
(luz_info at synthesis.ch)
More information about the fpc-devel
mailing list