This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[libjava] Fix signal handling on IRIX, Tru64 UNIX (PR libgcj/49315)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Cc: java-patches at gcc dot gnu dot org
- Date: Thu, 16 Jun 2011 14:11:07 +0200
- Subject: [libjava] Fix signal handling on IRIX, Tru64 UNIX (PR libgcj/49315)
While looking at the remaining libjava testsuite failures on IRIX 6.5
and Tru64 UNIX V5.1B, I noticed that both ports used default-signal.h
and can_unwind_signal is no, although both have implementations of
MD_UNWIND_FRAME_STATE_FOR. The following patch corrects this. Instead
of introducing yet another almost identical copy of solaris-signal.h,
I've generalized that file and now use it for all three ports as
posix-signal.h.
There's even more potential for merging existing *-signal.h files, but I
haven't approached that since I cannot test it.
As mentioned in posix-signal.h, some ports need SA_SIGINFO set in
sa_flags, while others cannot handle that condition. The file allows
for both. I'm currently defining SA_FLAGS appropriately in the header,
but one might want to do this outside.
Tested by sparc-sun-solaris2.11 and i386-pc-solaris2.11 bootstraps, as
well as rebuilding and re-testing libjava on alpha-dec-osf5.1b and
mips-sgi-irix6.5. The patch fixes the Throw_2 execution failures on
both platforms.
On Tru64 UNIX, this leaves us with
FAIL: md5test output - source compiled test
FAIL: md5test -findirect-dispatch output - source compiled test
FAIL: md5test -O3 output - source compiled test
FAIL: md5test -O3 -findirect-dispatch output - source compiled test
FAIL: shatest execution - source compiled test
FAIL: shatest -findirect-dispatch execution - source compiled test
FAIL: shatest -O3 execution - source compiled test
FAIL: shatest -O3 -findirect-dispatch execution - source compiled test
as reported in PR libgcj/49314. I'm still investigating what's going on
here, unfortunately gdb isn't any help and I have to do printf (well,
System.err.println) debugging instead.
On IRIX, there's
Running target unix
WARNING: program timed out.
FAIL: getstacktrace run
WARNING: program timed out.
FAIL: getallthreads run
FAIL: Thread_Interrupt output - source compiled test
FAIL: Thread_Interrupt -findirect-dispatch output - source compiled test
FAIL: Thread_Interrupt -O3 output - source compiled test
FAIL: Thread_Interrupt -O3 -findirect-dispatch output - source compiled test
I've not yet found what's going on here: the first two time out, the
third shows this output difference:
--- /vol/gcc/src/hg/trunk/local/libjava/testsuite/libjava.lang/Thread_Interrupt.out Mon Mar 1 20:33:06 2010
+++ Thread_Interrupt.out Fri Jun 10 17:14:23 2011
@@ -3,6 +3,6 @@
sleep()
interrupted - ok
Busy waiting
-interrupted - ok
+Error: Busy wait was not interrupted.
join()
interrupted - ok
I strongly suspect they are related.
FAIL: FileHandleGcTest execution - source compiled test
FAIL: FileHandleGcTest -findirect-dispatch execution - source compiled test
FAIL: FileHandleGcTest -O3 execution - source compiled test
FAIL: FileHandleGcTest -O3 -findirect-dispatch execution - source compiled test
This test fails with
/proc open failed
With par, one sees that after opening /dev/null many times, the /proc
open from boehm-gc fails:
1061mS[ 3]FileHandleGcTest(69051502): open("/dev/null", O_RDONLY, 0666) = 1022
1061mS[ 3]FileHandleGcTest(69051502): open("/dev/null", O_RDONLY, 0666) = 1023
1062mS[ 3]FileHandleGcTest(69051502): open("/dev/null", O_RDONLY, 0666) errno
= 24 (Too many open files)
1063mS[ 3]FileHandleGcTest(69051502): open("/proc/69051502", O_RDONLY, 0) errn
o = 24 (Too many open files)
1063mS[ 3]FileHandleGcTest(69051502): write(2, "/proc open failed\n", 18) = 18
open 1056 0.07 72.78
For some reason, FileNotFoundException isn't raised here.
While I don't formally need approval for this patch (it only affects my
targets), I'll wait a day before committing in case there are comments.
Thanks.
Rainer
2011-06-12 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libgcj/49315
* include/solaris-signal.h: Rename to ...
* include/posix-signal.h: ... this.
(SA_FLAGS): Define.
(SIGNAL_HANDLER): Handle non-SA_SIGINFO case.
(sa_signal_handler): Define.
(_INIT_SIG_HANDLER): New macro.
(INIT_SEGV, INIT_FPE): Use it.
* configure.ac (SIGNAL_HANDLER): Use it on alpha*-dec-osf*,
mips-sgi-irix*, *-*-solaris2*
* configure: Regenerate.
* include/aix-signal.h: Refer to AIX.
* configure.host (alpha*-dec-osf*): Enable can_unwind_signal.
(mips-sgi-irix6*): Likewise.
diff --git a/libjava/configure.ac b/libjava/configure.ac
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -1727,12 +1727,12 @@ SYSDEP_SOURCES=
SIGNAL_HANDLER_AUX=
case "${host}" in
+ alpha*-dec-osf* | mips-sgi-irix* | *-*-solaris2*)
+ SIGNAL_HANDLER=include/posix-signal.h
+ ;;
i?86-*-linux*)
SIGNAL_HANDLER=include/i386-signal.h
;;
- *-*-solaris2*)
- SIGNAL_HANDLER=include/solaris-signal.h
- ;;
# ia64-*)
# SYSDEP_SOURCES=sysdep/ia64.c
# test -d sysdep || mkdir sysdep
diff --git a/libjava/configure.host b/libjava/configure.host
--- a/libjava/configure.host
+++ b/libjava/configure.host
@@ -274,7 +274,10 @@ EOF
rm -f conftest conftest.c
fi
;;
- i[34567]86*-kfreebsd*-gnu | x86_64*-kfreebsd*-gnu)
+ alpha*-dec-osf*)
+ can_unwind_signal=yes
+ ;;
+ i[34567]86*-kfreebsd*-gnu | x86_64*-kfreebsd*-gnu)
libgcj_ld_symbolic='-Wl,-Bsymbolic'
slow_pthread_self=
;;
@@ -283,6 +286,7 @@ EOF
DIVIDESPEC=-f%{m32:no-}%{!m32:%{!m64:no-}}%{m64:}use-divide-subroutine
;;
mips-sgi-irix6* )
+ can_unwind_signal=yes
sysdeps_dir=mips
;;
arm*-linux* )
diff --git a/libjava/include/aix-signal.h b/libjava/include/aix-signal.h
--- a/libjava/include/aix-signal.h
+++ b/libjava/include/aix-signal.h
@@ -1,7 +1,7 @@
/* aix-signal.h - Catch runtime signals and turn them into exceptions,
- on a Darwin system. */
+ on a AIX system. */
-/* Copyright (C) 2008 Free Software Foundation
+/* Copyright (C) 2008, 2011 Free Software Foundation
This file is part of libgcj.
diff --git a/libjava/include/solaris-signal.h b/libjava/include/posix-signal.h
rename from libjava/include/solaris-signal.h
rename to libjava/include/posix-signal.h
--- a/libjava/include/solaris-signal.h
+++ b/libjava/include/posix-signal.h
@@ -1,6 +1,6 @@
-// sparc-signal.h - Catch runtime signals and turn them into exceptions.
+// posix-signal.h - Catch runtime signals and turn them into exceptions.
-/* Copyright (C) 1998, 1999, 2000, 2009 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2009, 2011 Free Software Foundation
This file is part of libgcj.
@@ -16,33 +16,45 @@ details. */
#define HANDLE_SEGV 1
#define HANDLE_FPE 1
+/* Different implementations of MD_FALLBACK_FRAME_STATE_FOR either require
+ SA_SIGINFO being set or fail if so. Cf. gcc/ada/init.c
+ (__gnat_install_handler) for details. */
+
+#if (defined __alpha__ && defined __osf__) \
+ || (defined __sun__ && defined __svr4__)
+#define SA_FLAGS SA_NODEFER | SA_SIGINFO
+#elif defined __sgi__
+#define SA_FLAGS SA_NODEFER
+#else
+#error Must define SA_FLAGS.
+#endif
+
+#if SA_FLAGS & SA_SIGINFO
#define SIGNAL_HANDLER(_name) \
static void _Jv_##_name (int, \
siginfo_t *_si __attribute__ ((__unused__)), \
void *_uc __attribute__ ((__unused__)))
+#define sa_signal_handler sa_sigaction
+#else
+#define SIGNAL_HANDLER(_name) \
+static void _Jv_##_name (int)
+#define sa_signal_handler sa_handler
+#endif
#define MAKE_THROW_FRAME(_exception)
-#define INIT_SEGV \
-do \
- { \
- struct sigaction act; \
- act.sa_sigaction = _Jv_catch_segv; \
- act.sa_flags = SA_SIGINFO | SA_NODEFER; \
- sigemptyset (&act.sa_mask); \
- sigaction (SIGSEGV, &act, NULL); \
- } \
-while (0)
-
-#define INIT_FPE \
-do \
- { \
- struct sigaction act; \
- act.sa_sigaction = _Jv_catch_fpe; \
- act.sa_flags = SA_SIGINFO | SA_NODEFER; \
- sigemptyset (&act.sa_mask); \
- sigaction (SIGFPE, &act, NULL); \
- } \
+#define _INIT_SIG_HANDLER(_SIG, _ACTION) \
+do \
+ { \
+ struct sigaction act; \
+ act.sa_signal_handler = _Jv_##_ACTION; \
+ act.sa_flags = SA_FLAGS; \
+ sigemptyset (&act.sa_mask); \
+ sigaction(_SIG, &act, NULL); \
+ } \
while (0)
+#define INIT_SEGV _INIT_SIG_HANDLER (SIGSEGV, catch_segv)
+#define INIT_FPE _INIT_SIG_HANDLER (SIGFPE, catch_fpe)
+
#endif /* JAVA_SIGNAL_H */
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University