FFI, signals and exceptions

Edward Z. Yang ezyang at MIT.EDU
Thu Aug 26 01:22:22 EDT 2010


Excerpts from Simon Marlow's message of Mon Aug 09 11:23:42 -0400 2010:
> That might be quite interesting to try, actually.  You'll need to modify the
> RTS: the place where we decide what to do when a throwTo is received for a
> thread involved in a foreign call is around line 396 of rts/RaiseAsync.c (in
> the HEAD):
> 
>      case BlockedOnCCall:
>      case BlockedOnCCall_NoUnblockExc:
>     blockedThrowTo(cap,target,msg);
>     return THROWTO_BLOCKED;
> 
> this is where you would call pthread_cancel (after checking for a bound 
> thread).  You should look into pthread_setcancelstate and 
> pthread_setcanceltype, and call these appropriately for worker threads.

I spent some time looking at the code, and I've been having a difficult
time finding the thread ID of the worker thread that is performing the
safe FFI call.  The target TSO is the suspended Haskell thread, which
afaict is distinct from the worker thread that is actually doing the FFI
call, so the obvious Tasks from bound/cap seem to be the wrong ones.
Do I have to walk all_tasks to find the one that's running the call I care
about?

Cheers,
Edward


More information about the Glasgow-haskell-users mailing list