
On 01/03/2010 17:06, Tyson Whitehead wrote:
If I have the following call sequence
C code -> Haskell code -> various C code bits
where the various C code bits on the right might do a longjmp (their version of an exception) and jumping back to the C code on the left.
eek.
Is it possible to have C code on the left then somehow tell GHC to cleanup the aborted Haskell code/resume executing it with an exception, or is the only option to setjmp wrap all the various C code bits on the right?
We don't have a way to do this, no. It would require some hacking in the RTS. The RTS has stashed away information about the call in progress and is expecting the call to return, so when you longjmp() the RTS will probably get very confused. For now I suggest you use setjmp. If you want to suggest an API to tell the RTS about a longjmp, then perhaps we could implement something, but I'm not sure what the API would look like, because you don't have a handle to the in-progress calls. In RTS-speak you need to tell the RTS about which Tasks have been terminated. I've actually been tinkering with this code a bit recently so there is now a structure called InCall which replaces some of what Task was for, but the idea is similar. Cheers, Simon