[Haskell-cafe] safe vs unsafe

Galchin, Vasili vigalchin at gmail.com
Tue Jun 24 15:08:00 EDT 2008

yes I am invoking a callback function written in Haskell.

On Tue, Jun 24, 2008 at 12:03 PM, Adam Langley <agl at imperialviolet.org>

> 2008/6/23 Galchin, Vasili <vigalchin at gmail.com>:
> > aio: schedule: re-entered unsafely.
> >    Perhaps a 'foreign import unsafe' should be 'safe'?
> >
> > I want to understand from an implementation viewpoint .. deeper. This is
> a
> > GC issue yes?
> Are you reentering Haskell on a path which involves an unsafe FFI
> call? e.g. you enter C land via an unsafe FFI call and, on the same
> call path, reenter Haskell with a callback?
> http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3<http://www.cse.unsw.edu.au/%7Echak/haskell/ffi/ffi/ffise3.html#x6-130003.3>says:
> "Optionally, an import declaration can specify, after the calling
> convention, the safety level that should be used when invoking an
> external entity. A safe call is less efficient, but guarantees to
> leave the Haskell system in a state that allows callbacks from the
> external code. In contrast, an unsafe call, while carrying less
> overhead, must not trigger a callback into the Haskell system. If it
> does, the system behaviour is undefined. The default for an invocation
> is to be safe. Note that a callback into the Haskell system implies
> that a garbage collection might be triggered after an external entity
> was called, but before this call returns. Consequently, objects other
> than stable pointers (cf. Section 5.6) may be moved or garbage
> collected by the storage manager."
> --
> Adam Langley agl at imperialviolet.org http://www.imperialviolet.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080624/bba50bf1/attachment.htm

More information about the Haskell-Cafe mailing list