[M3devel] exception handling and signal mask?

Tony Hosking hosking at cs.purdue.edu
Mon Jan 4 16:20:53 CET 2010


On 4 Jan 2010, at 06:50, Jay K wrote:

> "try" isn't supposed to save the signal mask, right?
> I mean..like..finally doesn't restore it, right?
> Nor does I suspect raise/except.

Good question.   No, exception handling mechanisms should not be responsible for this.  The design principle is usually to make TRY as fast as possible at the expense of the exceptional case.  Signal mask restoration should be programmed explicitly in a FINALLY clause.

> Specifically: Darwin.
> There should be underscores in Target.m3 there?

So, short answer on Darwin is to prefer _setjmp/_longjmp.

Same on all other platforms.

> 
> 
> Some of this /might/ be might fault.
> In particular I was unaware of this signal mask thing and its relationship to setjmp/longjmp.
> 
> 
> Furthermore, um... you know (or if you don't, I'll tell you):
> 
> 
> Many platforms have two versions of setjmp/longjmp.
> One saves/restore the signal mask. One does not.
> Sometimes I think it is via some #define to "steer" /usr/include/setjmp.h.
> Sometimes, I'm certain, it is setjmp vs. _setjmp, longjmp vs. _longjmp.
> 
> And then, furthermore, every system I've looked into recently except for NT
> offers sigsetjmp/siglongjmp.
> Their semantics when present are consistent.
> Albeit less efficient.
> sigsetjmp takes an extra integer (boolean) indicating of the signal mask should be saved.
> They use sigjmp_buf instead of jmp_buf, which is sometimes identical, sometimes one or two integers larger, or possibly even larger, depending on the size of the signal mask.
> 
> So...for the cost of sometimes enlarging the jmpbuf, and for the cost of passing the extra integer 0, maybe we should use sigsetjmp on all Unix systems? I believe the Solaris documentation warns about the "less clearly named functions" (my wording) changing semantic..though I kind of doubt they can do that..
> 
> 
> Not saving the signal mask is potentially much faster, as it might require a syscall to get.
> (Though I also wonder if it can't be a special thread local, like at a fixed offset from FS or GS as NT does it.)
> 
> 
> I'll go ahead and try just the smaller change of having Darwin use _setjmp instead of setjmp.
> Not going ahead with sigsetjmp. Just yet.
> 
>  - Jay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100104/12a92d60/attachment-0002.html>


More information about the M3devel mailing list