From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA18702 for caml-redistribution; Tue, 11 May 1999 10:38:59 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA31762 for ; Mon, 10 May 1999 11:10:26 +0200 (MET DST) Received: from ssti.mipnet.fr (ssti.mipnet.org [195.115.143.5] (may be forged)) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA16647 for ; Mon, 10 May 1999 11:10:24 +0200 (MET DST) Received: (from uucp@localhost) by ssti.mipnet.fr (8.8.7/8.8.7) id LAA16908 for ; Mon, 10 May 1999 11:09:08 +0200 (MET DST) Received: from clio(192.0.2.31) by ssti via smap (V1.3) id sma016902; Mon May 10 11:08:49 1999 Sender: weis Message-ID: <3736A408.865E2882@ssti.fr> Date: Mon, 10 May 1999 11:16:56 +0200 From: Didier PLAINDOUX X-Mailer: Mozilla 4.04 [en] (X11; I; SunOS 5.5.1 sun4u) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Some problems with Ocaml <-> C and GC ... Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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