gfxstrand / wayland-java

Java bindings for libwayland
Other
30 stars 5 forks source link

segfault #4

Open Zubnix opened 10 years ago

Zubnix commented 10 years ago

http://hastebin.com/inizaruyux.hs

Not sure what is the cause.

Zubnix commented 10 years ago

on the client side I ge this: Exception in thread "main" java.lang.RuntimeException: Broken pipe at org.freedesktop.wayland.client.Display.roundtrip(Native Method) at org.freedesktop.wayland.examples.simpleshm.Display.(Display.java:80) at org.freedesktop.wayland.examples.simpleshm.SimpleShm.main(SimpleShm.java:30)

Zubnix commented 10 years ago

I tried with wilee (core+jogl) and got a segfault on the same java calls.

Zubnix commented 10 years ago

The segfault happens on gentoo, when trying to reproduce on ubuntu no socket is created. Will try to reproduce and debug on arch.

Zubnix commented 10 years ago

build wayland from source, attached gdb, got no useful info(?)

0x00007f2a6a89e72f in pthread_join () from /lib64/libpthread.so.0 (gdb) step Single stepping until exit from function pthread_join, which has no line number information. [Thread 0x7f2a38081700 (LWP 23624) exited] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7f2a0928c700 (LWP 23649)] 0x00007f2a6aabaa7e in ?? () from /lib64/ld-linux-x86-64.so.2

gfxstrand commented 10 years ago

Yes, stepping after a segrault is just going to cause it to end. When it hits the segfault, could you do "bt full" in GDB and give me the output. On Jun 30, 2014 8:42 AM, "Zubnix" notifications@github.com wrote:

build wayland from source, attached gdb, got no useful info(?)

0x00007f2a6a89e72f in pthread_join () from /lib64/libpthread.so.0 (gdb) step Single stepping until exit from function pthread_join, which has no line number information. [Thread 0x7f2a38081700 (LWP 23624) exited] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7f2a0928c700 (LWP 23649)] 0x00007f2a6aabaa7e in ?? () from /lib64/ld-linux-x86-64.so.2

— Reply to this email directly or view it on GitHub https://github.com/jekstrand/wayland-java/issues/4#issuecomment-47547793 .

Zubnix commented 10 years ago

http://hastebin.com/ifosiyakut.django

Zubnix commented 10 years ago

When updating the get_env function to:

JNIEnv *
wl_jni_get_env()
{
JNIEnv * env;
// If this fails, things have gone very badly
int getEnvStat = (*java_vm)->GetEnv(java_vm, (void **)&env, JNI_VERSION_1_2);
if (getEnvStat == JNI_EDETACHED) {
fprintf(stdout, "env detached");
if ((*java_vm)->AttachCurrentThread(java_vm, (void **)&env, NULL) != 0) {
fprintf(stderr,"Failed to attach");
}
} else if (getEnvStat == JNI_OK) {
fprintf(stdout, "env attached");
} else if (getEnvStat == JNI_EVERSION) {
fprintf(stderr,"GetEnv: version not supported");
}
return env;
}

It no longer sefaults, however I get: /usr/lib/jvm/oracle-jdk-bin-1.8/bin/java: symbol lookup error: /tmp/libwayland-java-server.so: undefined symbol: wl_jni_get_env

On the client side (simpleshm client), it works just fine.

ldd libwayland-java-server.so ldd: warning: you do not have execution permission for `./libwayland-java-server.so' linux-vdso.so.1 (0x00007fff68512000) libwayland-java-util.so => not found libwayland-server.so.0 => /usr/lib64/libwayland-server.so.0 (0x00007fc8bd6a8000) libc.so.6 => /lib64/libc.so.6 (0x00007fc8bd306000) libffi.so.6 => /usr/lib64/libffi.so.6 (0x00007fc8bd0fe000) librt.so.1 => /lib64/librt.so.1 (0x00007fc8bcef5000) libm.so.6 => /lib64/libm.so.6 (0x00007fc8bcbfc000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc8bc9df000) /lib64/ld-linux-x86-64.so.2 (0x00007fc8bdada000)

gfxstrand commented 10 years ago

Yeah, that shouldn't be the problem. We don't need to do any thread re-attaching since wayland-java doesn't create any threads. What we do need is the ability to get the current env pointer without having been directly passed it by the JVM. We need that so we can do dispatching from functions that are called from within libwayland which is unaware of the JVM. We could probably find a way to patch the env pointer through if we're careful.

On Tue, Jul 1, 2014 at 3:02 AM, Zubnix notifications@github.com wrote:

When updating the get_env function to:

JNIEnv wl_jni_get_env() { JNIEnv * env; // If this fails, things have gone very badly int getEnvStat = (_java_vm)->GetEnv(java_vm, (void _)&env, JNI_VERSION_1_2); if (getEnvStat == JNI_EDETACHED) { fprintf(stdout, "env detached"); if ((_java_vm)->AttachCurrentThread(javavm, (void *)&env, NULL) != 0) { fprintf(stderr,"Failed to attach"); } } else if (getEnvStat == JNI_OK) { fprintf(stdout, "env attached"); } else if (getEnvStat == JNI_EVERSION) { fprintf(stderr,"GetEnv: version not supported"); } return env; }

It no longer sefaults, however I get: /usr/lib/jvm/oracle-jdk-bin-1.8/bin/java: symbol lookup error: /tmp/libwayland-java-server.so: undefined symbol: wl_jni_get_env

On the client side (simpleshm client), it works just fine.

— Reply to this email directly or view it on GitHub https://github.com/jekstrand/wayland-java/issues/4#issuecomment-47638312 .