Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Why systhreads?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-28 (09:17)
From: Quetzalcoatl Bradley <qbradley@b...>
Subject: [Caml-list] Calling ocaml from external threads

While the topic of threads is fresh...

Suppose you have an OCAML library (native code) to be embedded in a 
multithreaded C application.  The library is compiled with -output-obj 
unix.cmxa threads.cmxa and the C program calls caml_startup at the 

Then I create a few C threads and they all call into the ocaml library 
occasionally.  before calling in they first leave_blocking_section, and 
afterwards they call leave_blocking_section.

At this point, The first time a call is made into the ocaml, 
Mutex.create is called, which crashes during a GC inside 
"oldify_local_roots".  Hash_retaddr(retaddr) is called, and the result 
looked up in the frame_descriptors table, but the result is a NULL 
pointer which crashes when dereferenced.

Is there anything special that needs to be done to "bless" external 
threads before they call into ocaml?

Unfortunately it isn't really feasible for me to have ocaml create all 
the threads and have the C code called from ocaml instead.  I presume 
that would be easier though.


Quetzalcoatl Bradley
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: