Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Some problems with Ocaml <-> C and GC ...
@ 1999-05-10  9:16 Didier PLAINDOUX
  0 siblings, 0 replies; only message in thread
From: Didier PLAINDOUX @ 1999-05-10  9:16 UTC (permalink / raw)
  To: caml-list

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-05-11  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-10  9:16 Some problems with Ocaml <-> C and GC Didier PLAINDOUX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox