Date: Thu, 30 Jul 2020 06:09:02 +0000 From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 248360] calling timer_delete from OpenJDK twice causing a SIGSEGEV Message-ID: <bug-248360-7788@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248360 Bug ID: 248360 Summary: calling timer_delete from OpenJDK twice causing a SIGSEGEV Product: Ports & Packages Version: Latest Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: ports-bugs@FreeBSD.org Reporter: aploese@gmx.de Attachment #216874 text/plain mime type: Created attachment 216874 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D216874&action= =3Dedit Calling timer_delete twice from a native methd of java causing a SIGSEGEV Creating a timer and deleting that timer a second time does not set the err= no to EINVAL but crashes the whole VM (this happens in OpenBSD too... but not = on linux). calling timer_delete twice without returning to java after the first call w= ill succeed without a SIGSEGEV.=20 I don't know if this is an OpenJDK or a LibC bug or just a feature... simply run run.sh here files to reproduce the error file run.sh >>>> #!/bin/sh #linux export JAVA_HOME=3D/usr/lib/jvm/java-11-openjdk-amd64 #freebsd export JAVA_HOME=3D/usr/local/openjdk14/ gcc -fPIC TimerCreateDelete.c -I $JAVA_HOME/include -I $JAVA_HOME/include/l= inux -I $JAVA_HOME/include/freebsd -pthread -lrt || exit 1 ./a.out javac TimerCreateDelete.java || exit 1 gcc -c -fPIC TimerCreateDelete.c -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $JAVA_HOME/include/freebsd || exit 1 gcc -shared -o libTimerCreateDelete.so TimerCreateDelete.o -pthread -lrt || exit 1 java TimerCreateDelete `pwd` <<<< file TimerCreateDelete.c >>>> #include <jni.h> #include <time.h> #include <errno.h> #ifdef __cplusplus extern "C" { #endif static timer_t myTimer; /* * Class: TimerCreateDelete * Method: timer_create * Signature: ()I */ JNIEXPORT jint JNICALL Java_TimerCreateDelete_timer_1create (JNIEnv *env, jclass clazz) { if (timer_create(CLOCK_MONOTONIC, NULL, &myTimer)) { return errno; } else { return 0; } } /* * Class: TimerCreateDelete * Method: timer_delete * Signature: ()I */ JNIEXPORT jint JNICALL Java_TimerCreateDelete_timer_1delete (JNIEnv *env, jclass clazz) { if (timer_delete(myTimer)) { return errno; } else { return 0; } } int main(void) { puts("Run from native main");=20 int result;=20=20=20=20 result =3D Java_TimerCreateDelete_timer_1create(NULL, NULL); printf("time_create: %d\n", result);=20=20=20=20 result =3D Java_TimerCreateDelete_timer_1delete(NULL, NULL); printf("time_delete: %d\n", result);=20=20=20=20 result =3D Java_TimerCreateDelete_timer_1delete(NULL, NULL); printf("time_delete: %d\n", result);=20=20=20=20 puts("Timer destroyed");=20 return 0; } #ifdef __cplusplus } #endif <<<< file TimerCreateDelete.java >>>> /** * * @author aploese */ public class TimerCreateDelete { private static native int timer_create(); private static native int timer_delete(); public static void main(String[] args) { System.load(args[0] + "/libTimerCreateDelete.so"); int errno; System.out.println("Will call timer_create"); errno =3D timer_create(); System.out.println("timer_create errno: " + errno); System.out.println("Will call timer_delete first time"); errno =3D timer_delete(); System.out.println("timer_delete errno: " + errno); System.out.println("Will call timer_delete second time"); errno =3D timer_delete(); System.out.println("timer_delete errno: " + errno); } } <<<< --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-248360-7788>