Version française
Home     About     Download     Resources     Contact us    
Browse thread
Custom blocks and finalization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Custom blocks and finalization
On Wed, May 6, 2009 at 12:30, Dr. Thomas Fischbacher
<t.fischbacher@soton.ac.uk> > I take it you are referring to this part
of the documentation (18.9.1
> bottom):
>
> ===>
[snip]

Yes.

> Do not use CAMLparam to register
> the
> parameters to these functions, and do not use CAMLreturn to return the
> result.

Neither of the above will ever trigger a garbage collection, but they
are still prohibited.  I don't know why these restrictions are
required, but according to the documentation it seems dangerous to
manipulate any runtime datastructures while in a finalizer.

> Let's have a look at byterun/globroots.c:
[snip]
> So... how could caml_remove_global_root() actually trigger a heap GC?

It certainly doesn't, but it obviously manipulates runtime
datastructures which may not necessarily be in a state during
finalization where this is safe.  I'd have to study the runtime code
in detail to learn more, but maybe the OCaml team can clarify this
issue more quickly?

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com