caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: "David Mentré" <David.Mentre@irisa.fr>, caml-list@inria.fr
Subject: Re: Calling C from OCaml, GC problems
Date: Fri, 18 Feb 2000 10:45:23 +0100	[thread overview]
Message-ID: <20000218104523.12491@pauillac.inria.fr> (raw)
In-Reply-To: =?iso-8859-1?Q?=3Cwd8ael1noi1=2Efsf=40parate=2Eirisa=2Efr=3E=3B_from_Dav?= =?iso-8859-1?Q?id_Mentr=E9_on_Wed=2C_Feb_16=2C_2000_at_04=3A41=3A42PM_+0?= =?iso-8859-1?Q?100?=

>  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?

We've been through several designs for the "local root registration" API.
The CAMLxxx macros are the latest design, and the one that we think is
the easiest to use.  Most parts of the systems were written before
those macros were introduced, and thus still use an older API in 2.04
(but the next release of OCaml will use the new API).

>  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'

I think those warnings are harmless, and are due to the way the
CAMLxxx macros are written in 2.04.  But only Damien Doligez knows for
sure...

>  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:

That is often due to a local root not being registered, or being
incorrectly registered.

>     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)?

This shouldn't be a problem.  OCaml allocates its heap using malloc(),
and scans only the portions of the memory space that it allocated itself.
There might be funky interactions between sbrk() and malloc(), but
this is unlikely, as it would cause problem with the BDD library even
in C programs.

- Xavier Leroy



  parent reply	other threads:[~2000-02-21 17:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-16 15:41 David Mentré
2000-02-18  1:26 ` Markus Mottl
2000-02-18  9:45 ` Xavier Leroy [this message]
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=20000218104523.12491@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=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).