herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

JVM Fatal Error While Running Java FFI Tests For v1.39 #115

Closed feidens closed 3 years ago

feidens commented 3 years ago

While running make test_mcl in /ffi/java to compile the Java bindings for version v1.39, the tests crash via a fatal error of the JVM. Maybe related to #104.

The error results in the following log file: hs_err_pid26515.log

System: MacBook Pro (late 2012) i7 "Ivy Bridge" (I7-3615QM)

Click here for console output ``` make test_mcl JAVA_INC_DIR=/usr/local/opt/openjdk/include c++ mcl_wrap.cxx -o ../../lib/libmcljava.dylib -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -Wundef -m64 -I include -I test -fomit-frame-pointer -DNDEBUG -fno-stack-protector -O3 -DMCL_USE_VINT -DMCL_DONT_USE_OPENSSL -fPIC -I/usr/local/opt/openjdk/include/darwin -I/usr/local/opt/openjdk/include -I ../../include -I -Wno-strict-aliasing ../../lib/libmcl.a -m64 -shared ld: warning: object file (../../lib/libmcl.a(x86-64.o)) was built for newer macOS version (11.0) than being linked (10.15) javac MclTest.java cd ../../lib && LD_LIBRARY_PATH=../lib: java -classpath ../ffi/java MclTest libName : libmcljava.dylib curve=BN254 OK : x != y OK : x == z OK : x == 5 OK : x == 3 OK : x == 9 OK : x == 12 OK : x == 18 OK : x == ff OK : serialize OK : setLittleEndianMod OK : setHashOf OK : setHashOf - different P=0 P=1 6749776493001386509238500122918063823646445670146379117305170708628075411297 11887324660338845621811354321879393330675176348101959351731079754430340863058 P=1 13984708088367527633150625419565924312746055438312271548750077709069567012439 7202341352733729620909718804132746275448868602215312138995618664459920970978 P=1 13984708088367527633150625419565924312746055438312271548750077709069567012439 9595767378282102664031085338098987634440318519223757709938096761612832893745 OK : serialize Q=1 5071260612574847598154481551397490271738482315093155055895972943959549376287 10234727522655510421527469932557482401080410736874164343852306443442879080172 14604191607538439146493414339396910840996254529674015313604374393136045878019 5220266889721584775363643246163424385721050544860436446273705113581278958521 OK : P == P1 OK : serialize # # A fatal error has been detected by the Java Runtime Environment: # # SIGBUS (0xa) at pc=0x0000700005511928, pid=59637, tid=6147 # # JRE version: OpenJDK Runtime Environment (15.0.2+7) (build 15.0.2+7-27) # Java VM: OpenJDK 64-Bit Server VM (15.0.2+7-27, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64) # Problematic frame: # C 0x0000700005511928 # # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /Users/f/Documents/ambp/AG/mcl/lib/hs_err_pid59637.log # # If you would like to submit a bug report, please visit: # https://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # /bin/sh: line 1: 59637 Abort trap: 6 LD_LIBRARY_PATH=../lib: java -classpath ../ffi/java MclTest make: *** [test_mcl] Error 134 ```
herumi commented 3 years ago

Thank you for the report and I'm sorry that I reproduce the bug. I've fixed the bug at https://github.com/herumi/mcl/issues/113 and v1.40. I've append the test without adox/adcx at GitHub Action and so I don't expect that the bug will happen again.

feidens commented 3 years ago

Apparently the above error is not fixed. hs_err_pid44286.log

Click here for console output ``` make test_mcl JAVA_INC_DIR=/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/include c++ mcl_wrap.cxx -o ../../lib/libmcljava.dylib -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -Wundef -m64 -I include -I test -fomit-frame-pointer -DNDEBUG -fno-stack-protector -O3 -DMCL_USE_VINT -DMCL_DONT_USE_OPENSSL -fPIC -I/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/include/darwin -I/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/include -I ../../include -I -Wno-strict-aliasing ../../lib/libmcl.a -m64 -shared ld: warning: object file (../../lib/libmcl.a(x86-64.o)) was built for newer macOS version (11.0) than being linked (10.15) javac MclTest.java cd ../../lib && LD_LIBRARY_PATH=../lib: java -classpath ../ffi/java MclTest libName : libmcljava.dylib curve=BN254 OK : x != y OK : x == z OK : x == 5 OK : x == 3 OK : x == 9 OK : x == 12 OK : x == 18 OK : x == ff OK : serialize OK : setLittleEndianMod OK : setHashOf OK : setHashOf - different P=0 P=1 6749776493001386509238500122918063823646445670146379117305170708628075411297 11887324660338845621811354321879393330675176348101959351731079754430340863058 P=1 13984708088367527633150625419565924312746055438312271548750077709069567012439 7202341352733729620909718804132746275448868602215312138995618664459920970978 P=1 13984708088367527633150625419565924312746055438312271548750077709069567012439 9595767378282102664031085338098987634440318519223757709938096761612832893745 OK : serialize Q=1 5071260612574847598154481551397490271738482315093155055895972943959549376287 10234727522655510421527469932557482401080410736874164343852306443442879080172 14604191607538439146493414339396910840996254529674015313604374393136045878019 5220266889721584775363643246163424385721050544860436446273705113581278958521 OK : P == P1 OK : serialize # # A fatal error has been detected by the Java Runtime Environment: # # SIGBUS (0xa) at pc=0x00007000055af928, pid=44286, tid=9987 # # JRE version: OpenJDK Runtime Environment (15.0.2+7) (build 15.0.2+7-27) # Java VM: OpenJDK 64-Bit Server VM (15.0.2+7-27, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64) # Problematic frame: # C 0x00007000055af928 # # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /Users/f/Documents/ambp/AG/mcl/lib/hs_err_pid44286.log # # If you would like to submit a bug report, please visit: # https://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # /bin/sh: line 1: 44286 Abort trap: 6 LD_LIBRARY_PATH=../lib: java -classpath ../ffi/java MclTest make: *** [test_mcl] Error 134 ```
herumi commented 3 years ago

I did not read the attached log because of Maybe related to #104..

Does the following command run well?

make clean
make lib/libmcl.a bin/pairing.exe bin/emu -j4

bin/pairing.exe
bin/emu

I tested them with https://software.intel.com/content/www/us/en/develop/articles/pre-release-license-agreement-for-intel-software-development-emulator-accept-end-user-license-agreement-and-download.html , then -ivb(Ivy Bridge CPU) shows an error and -hsw(Haswell CPU) does not.

% sudo sde -ivb bin/emu
TID 0 SDE-ERROR: Executed instruction not valid for specified chip (IVYBRIDGE): 0x7fff20612a89: vpbroadcastb ymm0, xmm0
Image: /usr/lib/system/libsystem_platform.dylib+0x1a89 (in multi-region image, region# 0)
Function: __platform_strchr$VARIANT$Haswell
Instruction bytes are: c4 e2 7d 78 c0
feidens commented 3 years ago

Can be closed since everything works now. A new checkout solved it, hence it was my fault by not cleaning temp files or so. Sorry for the extra work.

herumi commented 3 years ago

Okay, the sde shows an error for int main() { puts("hello"); }, so we can use it for emulating Ivy Bridge.