I don't understand what you are saying.  When you say "works on Windows" do 
you mean that the build works?  I am certain that sig_on and sig_off do not 
work on Windows if you have not added any Windows-specific signal handling.


Yes, the build works on Windows as well as all tests are passing (to be 
precise: all tests that are meaningful on Windows and don't use 
unix-specific stuff). 

Among them are a few tests for sig_on/sig_off. But the implementation of 
these functions on Windows is very naïve. It simply doesn't use the 
setjmp/longjmp on Windows and doesn't implement any special handler. See 
https://github.com/sagemath/cysignals/blob/16b9d2bb714db3e670b004b4aa0d2250d78d8bf7/src/cysignals/implementation.c#L398-L400.
 
This works for the tests but I already had the feeling it's suboptimal as 
you just confirmed it.

The trick that we use in the CyPari version of cysignals to avoid this 
pitfall is that we exploit the fact that, in truth, there is one and only 
one signal handler on Windows which *does* run on the main execution stack 
of the process receiving the signal.  That is the handler for SIG_FPE - 
floating point exception (which usually does not terminate a process).  To 
make this work our special handler for, say, SIG_SEGV sets some global 
state and then raises SIG_FPE.   Our handler for SIG_FPE checks the global 
state  to decide whether the SIG_FPE is really a floating point exception 
or was raised by some other signal handler.


 I was hoping that you could migrate exactly these kind of "tricks" 
upstream to the sagemath/cysignals package. Once it has feature-parity with 
your modified version in cypari, you could migrate cypari to use the 
upstream cysignals package instead of having to maintain your own modified 
version.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sage-devel/8b3cffd3-2c6b-4b38-af32-5390b28c49dan%40googlegroups.com.

Reply via email to