nativelibs4java / BridJ

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

Crash with new NSDictionary() #100

Open marcprux opened 6 years ago

marcprux commented 6 years ago

BridJ's mvn test crashes after adding the following to ObjectiveCTest.java:

    @Test
    public void testNewNSDictionary() {
        if (!mac) return;
        NSDictionary dict = new NSDictionary();
    }   

The resulting hs_err_pid23369.log crash log starts with:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x00007fff57553c64, pid=23369, tid=0x0000000000001903
#
# JRE version: Java(TM) SE Runtime Environment (8.0_151-b12) (build 1.8.0_151-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.151-b12 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [CoreFoundation+0x13ec64]  -[__NSDictionary0 init]+0x4
#

Interestingly, if you rename "NSDictionary" to "NSCFDictionary", then it constructs fine. This makes me suspect that it has to do with the foundation collections being class clusters. End-user code could work around this by just using the static initializer methods to construct these instances, but the same crash will happen with any code that returns a Pointer, since BridJ will invoke the default constructor from org.bridj.CRuntime$CTypeInfo.newCastInstance(CRuntime.java:199).

Has any thought been given to supporting class clusters in the ObjC bindings?