On Fri, Jun 15, 2012 at 12:45:28PM +0200, Felix wrote: > > Other than figuring that out, it would be a good idea to test on mingw > > and OS X (I was going to do this). However testing on other platforms > > like cygwin or Solaris (or more obscure?) is problematic. It is not > > really a question of whether _setjmp works but if every platform supports > > _setjmp. I don't know if this is something to throw in before the > > release, if one is coming soon, unless we are going to test every > > supported platform before release. Anyone else? > > Changing this IMHO should be postponed until we have a new release.
After some more consideration, I think the signal mask reset bug warrants fixing it before the next release. Attached is a better patch which tries to avoid using fringe POSIX functions and instead simply using sigsetjmp()/siglongjmp() on platforms where we know they are supported. After asking on #chicken, "creidiki" tried the old patch on Windows and mentioned it didn't compile due to an undeclared function _longjmp (oddly, _setjmp *does* seem to exist...) so I haven't added sigsetjmp to Windows either. In any case, Windows doesn't have POSIX signals anyway so it doesn't matter which flavor of "*jmp" we use there. If someone using, say, Solaris or Haiku figures that sigsetjmp is supported on their platform after all, it's a simple matter of adding the define to Makefile.solaris or Makefile.haiku. At least this way it gets fixed on platforms that are known to have the signal problem. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth
>From 5999d00ed9b35db1f645890001ed941093a4a6bb Mon Sep 17 00:00:00 2001 From: Peter Bex <peter....@xs4all.nl> Date: Wed, 13 Jun 2012 22:54:26 +0200 Subject: [PATCH] Use sigsetjmp/siglongjmp instead of setjmp/longjmp on platforms where these are available to prevent inadvertent resetting of signal mask and the associated unneccessary system call overhead --- Makefile.bsd | 1 + Makefile.linux | 1 + Makefile.macosx | 1 + NEWS | 2 ++ chicken.h | 13 +++++++++++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile.bsd b/Makefile.bsd index 7c545af..4402c03 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -84,6 +84,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ + echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ echo "#define HAVE_STRERROR 1" >>$@ diff --git a/Makefile.linux b/Makefile.linux index 37f848c..c55d55e 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -73,6 +73,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ + echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ echo "#define HAVE_STRERROR 1" >>$@ diff --git a/Makefile.macosx b/Makefile.macosx index fdb2483..a0a73fa 100644 --- a/Makefile.macosx +++ b/Makefile.macosx @@ -97,6 +97,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ + echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ echo "#define HAVE_STRERROR 1" >>$@ diff --git a/NEWS b/NEWS index 4b31d83..136dbc9 100644 --- a/NEWS +++ b/NEWS @@ -241,6 +241,8 @@ and "-heap-shrinkage" - the assembly-language stub routine for the implementation of "apply" was broken for Sparc64 systems and has been disabled for this platform + - signal masks were accedentally reset upon GC for some platforms; use + sigsetjmp/siglongjmp on BSD, Linux and MacOS X - Type system - added new type-specifiers "input-port", "output-port", "(list-of T)" diff --git a/chicken.h b/chicken.h index 837a51c..6e9e009 100644 --- a/chicken.h +++ b/chicken.h @@ -874,8 +874,17 @@ DECL_C_PROC_p0 (128, 1,0,0,0,0,0,0,0) # define C_gettimeofday gettimeofday # define C_gmtime gmtime # define C_localtime localtime -# define C_setjmp setjmp -# define C_longjmp longjmp +/* + * It is undefined whether regular setjmp/longjmp save/restore signal mask + * so try to use versions that we know won't try to save & restore. + */ +# if defined(HAVE_SIGSETJMP) +# define C_setjmp(e) sigsetjmp(e, 0) +# define C_longjmp(e,v) siglongjmp(e, v) +# else +# define C_setjmp setjmp +# define C_longjmp longjmp +# endif # define C_alloca alloca # define C_strerror strerror # define C_isalpha isalpha -- 1.7.9.1
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers