Name: bsC130419 Date: 08/31/2001
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
The new 'signal chaining' facility in JDK 1.4 beta 2 appears to
not work for SIGUSR1. I am attaching a 'C' testcase that does the following
1) Sets up handlers for SIGSEGV and SIGUSR1
2) Starts the VM
3) Uses 'raise' to raise a SIGUSR1
4) Deliberateley overwrites storage to cause a SIGSEGV
The user signal handler set up gets invoked for the SIGSEGV, but not the
SIGUSR1. Output is as follows:
---------------------------------------------------------------------------
RFN: Starting. PID is 1403
Overriding SIGSEGV rc is 0
Overriding SIGUSR1 rc is 0
1) Setting signal handlers
RFN: creating the JVM ...
RFN: created JVM OK
>>>>>>>>>>>>>>>>>>>> robshandler 11
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0x10CFC
Function=crash+0x44
Library=stest
Current Java thread:
Dynamic libraries:
0x10000 ./stest
0xff370000 /usr/lib/libthread.so.1
0xff3b0000 /usr/lib/libdl.so.1
0xff280000 /usr/lib/libc.so.1
0xfee80000 /usr/java1.4.0/jre/lib/sparc/libjvm.so
0xff250000 /usr/lib/libCrun.so.1
0xfee60000 /usr/lib/libsocket.so.1
0xfed80000 /usr/lib/libnsl.so.1
0xfed50000 /usr/lib/libm.so.1
0xff350000 /usr/lib/libw.so.1
0xfed30000 /usr/lib/libmp.so.2
0xfee40000 /usr/platform/SUNW,Ultra-250/lib/libc_psr.so.1
0xfece0000 /usr/java1.4.0beta2/jre/lib/sparc/native_threads/libhpi.so
0xfecb0000 /usr/java1.4.0beta2/jre/lib/sparc/libverify.so
0xfec80000 /usr/java1.4.0beta2/jre/lib/sparc/libjava.so
0xfec50000 /usr/java1.4.0beta2/jre/lib/sparc/libzip.so
Local Time = Fri Aug 31 10:45:12 2001
Elapsed Time = 10
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.0-beta2-b77 mixed mode)
#
# An error report file has been saved as hs_err_pid1403.log.
# Please refer to the file for further information.
#
Abort(coredump)
----------------------------------------------------------------------------
As a check, if I comment out the code that starts the VM, I see both handlers
invoked correctly:
--------------------------------------
/people/robn/jdk14/signal ./stest
RFN: Starting. PID is 1567
Overriding SIGSEGV rc is 0
Overriding SIGUSR1 rc is 0
>>>>>>>>>>>>>>>>>>>> robshandler 16
>>>>>>>>>>>>>>>>>>>> robshandler 11
Segmentation Fault(coredump)
--------------------------------------
Code/Makefile are as follows:
--------------------------------------
#include <dlfcn.h>
#include <jni.h>
#include <signal.h>
#include <errno.h>
void set_sighandlers();
void crash();
void main()
{
fprintf(stderr,"RFN: Starting. PID is %d\n",getpid());
set_sighandlers();
{
JavaVMInitArgs vmArgs;
JavaVMOption *vmOptions;
JavaVM *jvm;
JNIEnv *jniEnv;
jclass cls;
jmethodID mid;
jstring jstr;
jobjectArray args;
jint rc;
fprintf(stderr,"1) Setting signal handlers\n");
vmOptions = (JavaVMOption *)malloc( sizeof(JavaVMOption) * 2 );
vmOptions[0].optionString = "-Djava.library.path=.";
vmOptions[1].optionString = "-XX:+AllowUserSignalHandlers";
vmArgs.version = JNI_VERSION_1_2;
vmArgs.options = vmOptions;
vmArgs.nOptions = 1;
vmArgs.ignoreUnrecognized = JNI_FALSE;
fprintf(stderr,"RFN: creating the JVM ...\n");
rc = JNI_CreateJavaVM(&jvm,(void **)&jniEnv,&vmArgs);
if (rc == 0)
{
fprintf(stderr,"RFN: created JVM OK\n");
}
else
{
fprintf(stderr,"RFN: creation of VM failed rrc=%d\n",rc);
}
}
sleep(10);
raise(SIGUSR1);
crash();
fprintf(stderr,"RFN: exiting\n");
}
void robshandler(int a)
{
fprintf(stderr,">>>>>>>>>>>>>>>>>>>> robshandler %d\n",a);
}
void set_sighandlers()
{
fprintf(stderr, "Overriding SIGSEGV rc is %d\n",
signal(SIGSEGV,robshandler));
fprintf(stderr, "Overriding SIGUSR1 rc is %d\n",
signal(SIGUSR1,robshandler));
}
void crash()
{
int i = 0;
int *p;
for (i = 0; i < 1e9; i++)
{
p = (int *)i;
*p = i;
}
}
--------------------------------------
JDKROOT=/usr/java1.4.0
IFLAGS=-I$(JDKROOT)/include -I$(JDKROOT)/include/solaris -I.
LFLAGS=-L$(JDKROOT)/jre/lib/sparc -lthread -ldl -lc -ljvm
RFLAGS=-R$(JDKROOT)/jre/lib/sparc
stest: stest.c
cc $(IFLAGS) -mt -c stest.c -o stest.o
cc -mt stest.o $(RFLAGS) $(LFLAGS) -o stest
@-rm -f stest.o
--------------------------------------
Note that the JDK 1.4 doc states:
'The new signal-chaining facility in J2SDK 1.4 supports pre-installed
signal handlers by saving any pre-installed signal handlers at the
time the VM is created.'
Note the use of the word 'any'. SIGUSR1 is also explicitly mentioned.
I'd like to take this opportunity to also request some far more detailed
documentation on the JVM's use of signals. We are using Java in our
transaction processing system, and Java is just one of the languages
that our customers can choose to code their business logic in. (COBOL
PL/I, and C being the others). We therefore treat the Java as
a 'small' subsystem that we invoke from our C control code. Having Java
replace our signal handlers in this way, without any options for us to
be the primary catcher of signals, is causing us extreme problems. Ideally
a mechanism where we could deliver signals to the VM as appropriate we be
preferable.
Please see the following bug for details of our earlier signal problems:
http://developer.java.sun.com/developer/bugParade/bugs/4366535.html
Thanks !
Rob
(Review ID: 131117)
======================================================================
- duplicates
-
JDK-4504050 Interrupted i/o reports i/o as not completed when it sometimes is completed.
-
- Closed
-