caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re:  Congratulation! Bug found!! (GC & C interfacing problems)
@ 2000-02-23 19:33 Damien Doligez
  0 siblings, 0 replies; 3+ messages in thread
From: Damien Doligez @ 2000-02-23 19:33 UTC (permalink / raw)
  To: caml-list

>From: David.Mentre@irisa.fr (David=?iso-8859-1?q?_Mentr=E9?=)

>I also subscribe to this documentation revision. I also volunteer, if
>needed, to review/rewrite the doc part related to Interfacing C with
>OCaml.

We are always very grateful for any contribution to the system and
especially the docs.  I've added a few notes in the doc based on your
story (as found in my mailbox when I came back from vacation), but I
guess what we really need is a better example to show all the features
of the interface.

-- Damien



^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: Still strange GC problems with OCaml and C: OCaml 2.04 bug?
@ 2000-02-21 20:10 Markus Mottl
  2000-02-22  9:16 ` Congratulation! Bug found!! (GC & C interfacing problems) David Mentré
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Mottl @ 2000-02-21 20:10 UTC (permalink / raw)
  To: David Mentré; +Cc: OCAML

> I'm still fighting against my bug while trying to interface OCaml with
> CMU bdd library (in C).

Hm, I have just taken a look at the code. I do not want to be too fast with
my suggestion (I have not tried it), but I am pretty sure that the
following might be the bug:

You use "Store_field" throughout the code to assign pointers to fields in
structures which were allocated using "alloc_final".

I once had a similar bug in my PCRE-library, but Gerd Stolpmann was so kind
to send me the patch and explain the problem. Here his translated
explanation (seems reasonable):

  - after "alloc_small" the fields have to be initialized with
    "Field(var, n) = ...", not with "Store_field". The last version writes
    (with some bad luck) the address of the field into a list of addresses
    which have to be moved in case of a minor GC.

  - The fields of "alloc_final" are not considered by the GC. Therefore,
    they, too, have to be written to using "Field(var, n)" (or you may
    cast them to a normal C-struct). "Store_field" has, again, unexpected
    side effects.

Since you are lucky and have used access macros throughout the code, you
can quickly test my suggestion by changing them.

I hope that helps!

In case this is really the bug (probably), I'd suggest a revision of the
C-interface-documentation. At least to me it was not obvious that
"Store_field" leads to such additional, unexpected behaviour.

Good luck squeezing the bug,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-02-24 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-23 19:33 Congratulation! Bug found!! (GC & C interfacing problems) Damien Doligez
  -- strict thread matches above, loose matches on Subject: below --
2000-02-21 20:10 Still strange GC problems with OCaml and C: OCaml 2.04 bug? Markus Mottl
2000-02-22  9:16 ` Congratulation! Bug found!! (GC & C interfacing problems) David Mentré
2000-02-22 16:27   ` Markus Mottl

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