ameisen / jdk-mc

Recent Java with modifications specific to Minecraft.
GNU General Public License v2.0
38 stars 1 forks source link

Crash Loading Mekanism Mod #10

Closed brucethemoose closed 2 years ago

brucethemoose commented 3 years ago

The Enigmatica 6 pack crashes when attempting to load it with the v15-mc+0-mc-60001 Haswell windows release. Forge mentions 2 errors related to Mekanism.

latest.log: https://paste.ee/p/gYTdF

crash-fml.txt: https://paste.ee/p/j6nIx

I understand giant 1.16 Forge packs are not really what this release is aimed at, but I figured this was worth reporting.

leo60228 commented 3 years ago

The root cause of this seems to be java.lang.UnsatisfiedLinkError: 'double java.lang.Math.log10(double)'.

leo60228 commented 3 years ago

This is a strange error, since this method exists in both upstream Java 15 and this fork:

leo60228 commented 3 years ago

This call is at https://github.com/mekanism/Mekanism/blob/b0a96e1eb7b5f5741cb1ca2f4ce656084ae923d5/src/main/java/mekanism/common/lib/radiation/RadiationManager.java#L356.

ameisen commented 3 years ago

This is almost certainly my fault, and I will fix it in my next push prior to migrating to Java 16.

I had been doing work on Math and StrictMath to both add support for single-precision operations, and to change the underlying libraries used for StrictMath to get better performance. However, I did it naively, and it broke a lot of things. When I reverted it, I likely failed to properly revert an original source reference for that function.

What you can see is that Math.log10 actually defers to StrictMath.log10, which itself is a native function.

Native calls need to be looked up via JNI information, which is provided in various files that are both hand-written and autogenerated. In this case, the issue will be in StrictMath.c.

Right now, it is defined here: https://github.com/ameisen/jdk-mc/blob/mc-15/src/java.base/share/native/libjava/StrictMath.c#L58

This will expand to:

JNIEXPORT jdouble JNICALL
Java_java_lang_StrictMath_log10__D (JNIEnv *env, jclass unused, jdouble v) {
    return jlog10(v);
}

JNIEXPORT jfloat JNICALL
Java_java_lang_StrictMath_log10__F (JNIEnv *env, jclass unused, jfloat v) {
    return jlog10(v);
}

However, in this case, the build you're running has Math's set as its own, native function... which is not correct. At least in the sense that it cannot find an actual function to link against.

Which version of jdk-mc is this?

brucethemoose commented 3 years ago

Which version of jdk-mc is this?

v15-mc+0-mc-60001 from Jan 20. In March I was running the Haswell Windows build, but I just confirmed it happens with the Zen 2 linux version as well.