[Mono-list] Using ld wrapping with Boehm GC
Patrick Hartling
patrick@vrac.iastate.edu
Tue, 29 Jun 2004 09:56:23 -0500
--=-tF+VqWIo1SPttxYK/7Ih
Content-Type: multipart/mixed; boundary="=-GDwj3WIotmdRBgEv1bmh"
--=-GDwj3WIotmdRBgEv1bmh
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
I am working on a project that mixes native code with the CLI, and I am
having problems with threading. The problems arise because the native
code creates its own threads, and those threads can call into the CLI
universe. To handle this, I have code that bridges between the native
code and the CLI, and in places where a thread spawned by the native
code will call into the CLI universe, mono_thread_attach() is called
first. Unfortunately, this does not seem to be sufficient.
What I am seeing is that my code can run for a few seconds, but then it
crashes consistently at the end of the Boehm GC function
pthread_push_all_stacks(). The full stack trace of the crash is
attached. (Note that I am using Mono 0.97 on Fedora Core 1 with the
Boehm GC code that comes bundled with the Mono runtime source.) The
crash appears to occur because Boehm GC does not know about at least one
of the threads created by the aforementioned native code.
I cannot modify the native code to use GC_pthread_create() and friends,
so I am trying to find a way to let Boehm GC know about the threads
created by the native code. I have done a little bit of digging, and I
see that Boehm GC can use the function call wrapping feature of GNU ld.=20
However, I do not see anything in the Mono build process that enables or
takes advantage of this feature.
I am prepared to take steps to try out this capability of Boehm GC and
GNU ld, but before I do, I am curious to know if there is something in
Mono's API that I can call to register externally created threads with
the garbage collector. mono_thread_attach() by itself does not appear
to be quite enough for my case, but I may be missing something. Is
there another Mono API call I can make or some Boehm GC thread
registration call? If not, I will go ahead with the function call
wrapping via ld in hopes of getting my code to work.
-Patrick
--=20
Patrick L. Hartling | Research Assistant, VRAC
http://www.137.org/patrick/ | 2274 Howe Hall Room 2624
PGP: http://tinyurl.com/ywd54 | http://www.vrac.iastate.edu/
--=-GDwj3WIotmdRBgEv1bmh
Content-Disposition: attachment; filename=gc-crash.txt
Content-Type: text/plain; name=gc-crash.txt; charset=UTF-8
Content-Transfer-Encoding: base64
IzAgIDB4MDAzMWFjMzIgaW4gX2RsX3N5c2luZm9fa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ob21lL3VzZXJzL3BhdHJpY2svc3JjL0p1Z2dsZXIvbWFpbi9qdWdnbGVyL2J1aWxkLmxp
bnV4LWZjMS5wb3NpeC5nY2MzMy9pbnN0bGlua3MvbGliL2k2ODYvbGlidnJqLnNvDQojMjQgMHgw
NDhlMzNlOCBpbiA/PyAoKQ0KIzI1IDB4MDAzNTVjNTQgaW4gX19ub3JtYWxfaXRlcmF0b3IgKHRo
aXM9MHg5Njg1ZjgwLCBfX2k9QDB4MCkNCiAgICBhdCBzdGxfaXRlcmF0b3IuaDo1OTMNCiMyNiAw
eDAwNTMxYTE0IGluID8/ICgpDQojMjcgMHgwOTY4NWY4MCBpbiA/PyAoKQ0K
--=-GDwj3WIotmdRBgEv1bmh--
--=-tF+VqWIo1SPttxYK/7Ih
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQBA4YMX5DgSg+v4Y5gRAl5OAJoCRbt+7gcdrCdP8P7Z2anfPC/XaACgpc12
lzSSKScSmekjCv40XpnIW6g=
=PR65
-----END PGP SIGNATURE-----
--=-tF+VqWIo1SPttxYK/7Ih--