Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
OCaml - CInterface: interesting bug scenario
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-06-01 (15:13)
From: Sven LUTHER <luther@m...>
Subject: Re: OCaml - CInterface: interesting bug scenario
On Thu, May 27, 1999 at 02:58:18PM -0700, Manuel Fahndrich wrote:
> The scenario looks like a rare event, but I was able to observe this bug
> consistently. There are several fixes one can imagine:
> 1) keep ML and C blocks separate throughout the lifetime of a process.
> 2) Box every C pointer inside an abstract ML block. This way, the garbage
> collector will never look at the pointer. Unfortunately this causes a lot of
> extra allocation and indirection.
> 3) Tag C pointers as integers by setting the least significant bit whenever
> the pointer is passed to ML or stored in the ML heap. Similarly, clear the
> bit whenever the pointer is examined on the C side.

Another solution would be to wrap the malloc and other such functions, to
inform the caml system that the block as been freed, would it not ?