[Starkit] TclKit segfault when using an extension
Trevor Davel
TrevorD at prism.co.za
Wed May 24 16:55:07 CEST 2006
Thanks for the help everyone,
I think we need a FAQ on this ;)
> > The possibilities I haven't managed to look into yet are:
> > - Possible pthreads / -D_REENTRANT conflict when both the
> > tcl interpreter and extension use libstdc++. Is there any
> > way I can compile TclKit with threads enabled?
>
> Yes, but you should be able to grab the dqkit, which has threaded builds
> already. This would be my first guess for a problem area.
I'm not sure if dqkit works, but I managed to find a threaded build of
TclKit (http://e-lehmann.de/?page_id=31) and got it working. TclKit-lite
also works.
I had tried TclKit-lite but still got segfault problems. They turned out to
be a problem in our extension (a pointer was never initialised by was
assumed to have been initialised to NULL), which never showed up under the
default build of Tcl on the platform, or other C & Java test code (our
extension has C, JNI and Tcl interfaces). This threw me off because I saw a
segfault and assumed it was a library conflict ;(
I saw similar problems when I tried dqkit, so it probably will work.
So for posterity, the story as I know it now:
(A) static TclKit on Linux + dynamically linked .so extension (using
pthreads & C++) = bad.
Segfault in libstdc++ as soon as you attempt to load the library.
(B) dynamic TclKit on Linux + dynamically linked .so extension (using
pthreads & C++) = bad.
Some C++ code may cause segfaults (in libstdc++ or pthreads); I assume
because of the differences between code compiled with -D_REENTRANT and
without.
(C) dynamic threaded TclKit on Linux + dynamically linked .so extension
(using pthreads & C++) = ok.
(D) dynamic TclKit-lite on Linux + dynamically linked .so extension (using
pthreads & C++) = ok.
This appears to be fine because there is no conflict over the manner of use
of libstdc++. I would guess that if another extension (without pthreads)
also used C++, there would be problems.
I think the lesson here is to get the binary and all libraries that will
coexist in the process to agree upon whether they are all threaded
(-D_REENTRANT) or all not threaded.
Regards,
Twylite
More information about the Starkit
mailing list