Browse thread
Segfaults with Dynlink with OCaml 3.11
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Paul Steckler <steck@s...> |
| Subject: | Re: Segfaults with Dynlink with OCaml 3.11 |
On Mon, Aug 23, 2010 at 8:57 PM, Paul Steckler <steck@stecksoft.com> wrote:
> I'm getting segmentation faults when using dynamically linked native
> code in 64-bit OCaml 3.11 running on Linux (Fedora 12 x64).
Many thanks to all who gave useful advice on tracking down this problem.
We have three chunks of C code we're calling, so we went through those
and audited our use of the FFI conventions. Indeed, we found a number
of instances where we used return instead of CAMLreturn, and so on.
But the segfaults were occurring before our C code was ever called,
and before any code was called in OCaml packages we use that are
linked against C code, such as sqlite3. So the segfaults occurred
even after patching our C code.
Today, I found the culprit. Here's the pattern:
dynamically load .cmxs file
query list mutated by .cmxs file (* no problem *)
Gc.set { (Gc.get()) with Gc.minor_heap_size = ...};
Gc.set { (Gc.get()) with Gc.major_heap_increment = ... };
query mutated list (* segfault! *)
If I move the Gc.set's to the program initialization code, before the
loading of dynamic code, no segfaults occur.
Is this expected behavior? I don't see caveats about interaction with
the garbage collector in the documentation for the Dynlink module, nor
anything about dynamic linking in the Gc module documentation.
-- Paul