Some problems with Ocaml <-> C and GC ...

From: Didier PLAINDOUX (didier@ssti.fr)
Date: Mon May 10 1999 - 11:16:56 MET DST


Date: Mon, 10 May 1999 11:16:56 +0200
From: Didier PLAINDOUX <didier@ssti.fr>
To: caml-list@inria.fr
Subject: Some problems with Ocaml <-> C and GC ...

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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:22 MET