libgcj signal handling problem

Andrew Haley aph@redhat.com
Tue Aug 19 09:31:00 GMT 2003


Andrew Morton writes:
 > 
 > Folks,
 > 
 > libgcj's detection of bad pointers is broken on Linux 2.6 kernels because it is
 > using setjmp()/longjmp() rather than sigsetjmp()/siglongjmp().
 > 
 > Details at http://bugme.osdl.org/show_bug.cgi?id=1124
Thanks for the heads up. I imagine this kernel change will break some
other code, as well. :-(
Hans, I don't know if you already use sigsetjmp()/siglongjmp() to
leave your SEGV handlers, but if you don't this is the time to make
the change.
Andrew, I have appended a patch. I'd be grateful if you would try
this patch on the system where you observed the problem.
I'll check this in to trunk and branch.
Thanks,
Andrew.
2003年08月19日 Andrew Haley <aph@redhat.com>
	* prims.cc (unblock_signal): New function.
	(SIGNAL_HANDLER): Use it.
	(SIGNAL_HANDLER): Likewise.
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.81
diff -p -2 -c -r1.81 prims.cc
*** prims.cc	21 Jul 2003 01:54:05 -0000	1.81
--- prims.cc	19 Aug 2003 09:21:02 -0000
*************** void (*_Jv_JVMPI_Notify_THREAD_END) (JVM
*** 123,126 ****
--- 123,140 ----
 
 
+ /* Unblock a signal. Unless we do this, the signal may only be sent
+ once. */
+ static void 
+ unblock_signal (int signum)
+ {
+ #ifdef _POSIX_SOURCE
+ sigset_t sigs;
+ 
+ sigemptyset (&sigs);
+ sigaddset (&sigs, signum);
+ sigprocmask (SIG_UNBLOCK, &sigs, NULL);
+ #endif
+ }
+ 
 #ifdef HANDLE_SEGV
 SIGNAL_HANDLER (catch_segv)
*************** SIGNAL_HANDLER (catch_segv)
*** 128,131 ****
--- 142,146 ----
 java::lang::NullPointerException *nullp 
 = new java::lang::NullPointerException;
+ unblock_signal (SIGSEGV);
 MAKE_THROW_FRAME (nullp);
 throw nullp;
*************** SIGNAL_HANDLER (catch_fpe)
*** 138,141 ****
--- 153,157 ----
 java::lang::ArithmeticException *arithexception 
 = new java::lang::ArithmeticException (JvNewStringLatin1 ("/ by zero"));
+ unblock_signal (SIGFPE);
 #ifdef HANDLE_DIVIDE_OVERFLOW
 HANDLE_DIVIDE_OVERFLOW;


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /