[Bug 248360] calling timer_delete from OpenJDK twice causing a SIGSEGEV
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Jul 30 06:09:02 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248360
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 at FreeBSD.org
Reporter: aploese at gmx.de
Attachment #216874 text/plain
mime type:
Created attachment 216874
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=216874&action=edit
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 errno
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 will
succeed without a SIGSEGEV.
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=/usr/lib/jvm/java-11-openjdk-amd64
#freebsd
export JAVA_HOME=/usr/local/openjdk14/
gcc -fPIC TimerCreateDelete.c -I $JAVA_HOME/include -I $JAVA_HOME/include/linux
-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");
int result;
result = Java_TimerCreateDelete_timer_1create(NULL, NULL);
printf("time_create: %d\n", result);
result = Java_TimerCreateDelete_timer_1delete(NULL, NULL);
printf("time_delete: %d\n", result);
result = Java_TimerCreateDelete_timer_1delete(NULL, NULL);
printf("time_delete: %d\n", result);
puts("Timer destroyed");
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 = timer_create();
System.out.println("timer_create errno: " + errno);
System.out.println("Will call timer_delete first time");
errno = timer_delete();
System.out.println("timer_delete errno: " + errno);
System.out.println("Will call timer_delete second time");
errno = timer_delete();
System.out.println("timer_delete errno: " + errno);
}
}
<<<<
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-ports-bugs
mailing list