Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Didier PLAINDOUX <didier@ssti.fr>
To: caml-list@inria.fr
Subject: Some problems with Ocaml <-> C and GC ...
Date: Mon, 10 May 1999 11:16:56 +0200	[thread overview]
Message-ID: <3736A408.865E2882@ssti.fr> (raw)

Hello,

Actually i connect SP (Sgml parser of J. Clark) to Ocaml.
This connection is based on Ocaml to C and C to Ocaml
callbacks. I use (i hope in a good way) all Caml allocations
in order to "live in harmony" with the GC.

For Example :
|value mkCouple(value left,value right) {
|   CAMLparam2(left,right);
|   CAMLlocal1(_obj);
|   _obj = alloc_tuple(2);
|   Store_field(_obj,0,left);
|   Store_field(_obj,1,right);
|   CAMLreturn _obj;
|};

|value dispatchDTDMessage(value group,value event,DtdElementDefinition*
p_spDtd) {
|   CAMLparam2(group,event);
|   static value * group_call_closure_dtd = NULL;
|   if (group_call_closure_dtd == NULL) {
|      group_call_closure_dtd = caml_named_value("dispatchDTDMessage");
|   };
|   CAMLreturn
callback3(*group_call_closure_dtd,group,event,(value)p_spDtd);
|};

In fact, if after each callback (C -> Ocaml) i do not invocate
Gc.full_major ()
i have a core dumped. In the other case (Gc.full_major () is applied)

| let dispatchDTDMessage (g : ('dtd)groupParserType) (ev : lsdDTDEvent)
(c:spDtd) =
| Gc.full_major ();
| match ev with ...

the computation works and terminate normally ...

For instance, i build a DTD using injective types and if i print this
TERM
on stdout and do DTD comparison (for example) there is no problem.
But if i do not print this TERM in stdout i also have a core dumped as
result !

Gc trace when Verbose = 123 :
| <>Starting new major GC cycle
| allocated_words = 3880
| extra_heap_memory = 3000u
| amount of work to do = 77483u
| Marking 13957 words
| ! Starting new major GC cycle
| Illegal instruction (core dumped)

Thanks for any help ...

Didier





                 reply	other threads:[~1999-05-11  8:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3736A408.865E2882@ssti.fr \
    --to=didier@ssti.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