
Hello, At runtime, I am getting .... 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? Kind regards, Vasili

2008/6/23 Galchin, Vasili
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 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@imperialviolet.org http://www.imperialviolet.org

yes I am invoking a callback function written in Haskell.
On Tue, Jun 24, 2008 at 12:03 PM, Adam Langley
2008/6/23 Galchin, Vasili
: 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.3http://www.cse.unsw.edu.au/%7Echak/haskell/ffi/ffi/ffise3.html#x6-130003.3says:
"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@imperialviolet.org http://www.imperialviolet.org

On Tue, Jun 24, 2008 at 12:08 PM, Galchin, Vasili
yes I am invoking a callback function written in Haskell.
Then you should just need to remove the "unsafe" from the foreign import decl which leads to the callback getting called. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org
participants (2)
-
Adam Langley
-
Galchin, Vasili