nativelibs4java / BridJ

BridJ: blazing fast Java / C / C++ interop
https://code.google.com/archive/p/bridj/
Other
289 stars 77 forks source link

Nullpointer inside direct native call #78

Closed Zubnix closed 8 years ago

Zubnix commented 8 years ago

I have a program that makes native calls in 'direct' mode eg. @Ptr long. After the the GC runs I immediately get a Nullpointer which seems to come from inside the native call. The method accepts a single argument a @Ptr long from an opaque struct. I can confirm the pointer peer is not 0L, nor is the Pointer object from which it is derived GC. This issue also happens with BRIDJ_DEBUG_NEVER_FREE=1 and BRIDJ_DIRECT=0. Jdk is 1.8.0u60

It seems that whatever is happening inside the native call tries to reach a GC object. Unfortunately I can not/know not how to debug this problem.

Any pointers? (pun intended). This happens on 0.7.0 and on current 0.7.1-SNAPSHOT

stacktrace:

java.lang.NullPointerException
    at org.freedesktop.wayland.client.bridj.WaylandClientLibrary.wl_display_dispatch(Native Method)
    at org.freedesktop.wayland.client.Display.dispatch(Display.java:149)
    at examples.SimpleShm.main(SimpleShm.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Zubnix commented 8 years ago

The problem seems to have been a GC callback object.