[Mono-devel-list] [PATCH] issue with libmono.so and dlopen

Robert Jordan robertj at gmx.net
Sat Jun 25 09:11:58 EDT 2005


I ran into a problem with dlopen and libmono.so. It appears
that the one and only __thread variable of libgc will
get the tls-model "global-dynamic", which doesn't seem to
be compatible with dlopen(3). I don't know whether this is
a bug or a "by design" feature.

Mini uses  __attribute__((tls_model("local-exec"))) for
__thread variables, if applicable, so I just added
the same code block I found in mono-compiler.h
to libgc/pthread_support.c

The patch will probably speed-up the GC a little bit, although
I did't profile it.

I'm not happy with the attached patch because it duplicates
code between mini and libgc, so I'd provide another patch,
if you guys would accept this solution:

configure.is probes whether the GCC switch -ftls-model
is working. If yes, -ftls-model=local-exec will be added
to the CFLAGS of Mono and libgc. MONO_FAST_TLS can be


ps: the attached "foo.c" is a test case for the problem.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tls.diff
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050625/a43781eb/attachment.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 455 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050625/a43781eb/attachment.bin 

More information about the Mono-devel-list mailing list