caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David.Mentre@irisa.fr (David Mentré)
To: caml-list@inria.fr
Subject: Calling C from OCaml, GC problems
Date: 16 Feb 2000 16:41:42 +0100	[thread overview]
Message-ID: <wd8ael1noi1.fsf@parate.irisa.fr> (raw)

Hello all Camlists,

A friend of mine and me are trying to interface CMU bdd library (in C)
with OCaml. We have a rough code but a bug is still alive. I still have
some questions relative to OCaml and C interfacing:

 1. the ocaml doc (paragraph 15.5) states that CAMLparam and CAMLreturn
    macros should be used. However, example code in 15.7 does not use
    them (even if functions have value typed parameters). The Unix
    interfacing code ocaml-2.04/otherlibs/unix/) doesn't use those macro
    either. Faulty doc?  Are those macros not mandatory? What is the
    rationale?

 2. when compiling, I've tons of warning like this:
bdd_interface.c: In function `mlbdd_alloc_manager':
bdd_interface.c:136: warning: left-hand operand of comma expression has no effect
bdd_interface.c:136: warning: unused variable `caml__dummy_result'

    the corresponding C code is:
value mlbdd_alloc_manager(MANAGER m) {
        CAMLparam0();
        CAMLlocal1 (result);  

        bdd_overflow_closure(m, mlbdd_overflow, NULL);
        result = alloc_final(Size_ml_manager, mlbdd_free_manager, 0, 1);
        Manager_store_pointer(result, (value)m);
        PRINT_DEBUG("Alloc manager");
        CAMLreturn result;
}

    Did I use wrongly those CAML* macros?

 3. The code is running on small examples but segfault on bigger
    ones. From gdb backtrace, it seems clear that my bug is releated to
    a GC problem:
(gdb) bt
#0  0x8065c45 in mark_slice ()
#1  0x806607b in major_collection_slice ()
#2  0x8066663 in minor_collection ()
#3  0x80666ac in check_urgent_gc ()
#4  0x805ba53 in alloc_final ()
#5  0x804e0fc in mlbdd_alloc_vbdd (m=0x809f020, b=0x80f55b9) at bdd_interface.c:204
#6  0x804ec85 in mlbdd_or (vb1=717431320, vb2=717431288) at bdd_interface.c:441
#7  0x80645bb in interprete ()
#8  0x80656d3 in caml_main ()
#9  0x805b1d5 in main ()
#10 0x2ab457e2 in __libc_start_main () from /lib/libc.so.6

    The bdd library is using itself a memory management library calling
    sbrk(2). Can it trigger problems with OCaml GC (like the GC going
    into bdd structures)?

Below URL's to C and OCaml interface codes if somebody need them:
  http://www.irisa.fr/paris/pages-perso/David-Mentre/bdd.ml
  http://www.irisa.fr/paris/pages-perso/David-Mentre/bdd_interface.c


Many thanks in advance for any help.

best regards,
david
-- 
 David.Mentre@irisa.fr -- http://www.irisa.fr/prive/dmentre/
 Opinions expressed here are only mine.



             reply	other threads:[~2000-02-17 23:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-16 15:41 David Mentré [this message]
2000-02-18  1:26 ` Markus Mottl
2000-02-18  9:45 ` Xavier Leroy
2000-02-21 16:54   ` David Mentré
2000-02-21 23:41     ` Max Skaller
2000-02-18 10:48 ` Juan J. Quintela
2000-02-21 13:40   ` David Mentré
2000-02-23 19:39 Damien Doligez
2000-02-24 23:36 ` Max Skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wd8ael1noi1.fsf@parate.irisa.fr \
    --to=david.mentre@irisa.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).