JNA concurrency issues -
i'm trying access native (fortran) library (mylib.so
) loaded jna. library accessed in parallal spark-job. far have not synchronized method calls (nor library) call shared library bottleneck in computations , must run in parallel.
i following error:
# fatal error has been detected java runtime environment: # # sigsegv (0xb) @ pc=0x00007ffbcb5f8dcd, pid=58569, tid=140708155152128 # # jre version: java(tm) se runtime environment (8.0_60-b27) (build 1.8.0_60-b27) *** error in `/usr/java/jdk1.8.0_60/jre/bin/java': double free or corruption (!prev): 0x0000000001b756d0 *** *** error in `/usr/java/jdk1.8.0_60/jre/bin/java': free(): corrupted unsorted chunks: 0x0000000001b75010 *** *** error in `/usr/java/jdk1.8.0_60/jre/bin/java': double free or corruption (!prev): 0x0000000001b756d0 *** # java vm: java hotspot(tm) 64-bit server vm (25.60-b23 mixed mode linux-amd64 compressed oops) # problematic frame: # c [libc.so.6+0x38dcd]======= backtrace: ========= ======= backtrace: ========= ======= backtrace: ========= /lib64/libc.so.6(+0x7d053)[0x7ffbcb63d053] /lib64/libc.so.6(+0x7d053)[0x7ffbcb63d053] /lib64/libc.so.6(+0x7d053)[0x7ffbcb63d053] /lib64/libc.so.6(+0x38e90)[0x7ffbcb5f8e90] /usr/java/jdk1.8.0_60/jre/lib/amd64/server/libjvm.so(+0x5d43f9)[0x7ffbcabba3f9] /lib64/libc.so.6(+0x38e90)[0x7ffbcb5f8e90] /lib64/libc.so.6(+0x38eb5)[0x7ffbcb5f8eb5] /lib64/libc.so.6(+0x38e69)[0x7ffbcb5f8e69] /lib64/libc.so.6(+0x38eb5)[0x7ffbcb5f8eb5] __run_exit_handlers+0x3d # # failed write core dump. core dumps have been disabled. enable core dumping, try "ulimit -c unlimited" before starting java again # /opt/usr/local/lib/mylib.so(for_exit+0x19)[0x7ff9285b0fa9] /lib64/libc.so.6(+0x38eb5)[0x7ffbcb5f8eb5] /opt/usr/local/lib/mylib.so(for_exit+0x19)[0x7ff9285b0fa9] /opt/usr/local/lib/mylib.so(for__once_private+0x27)[0x7ff9285660b7] /opt/usr/local/lib/mylib.so(for__once_private+0x27)[0x7ff9285660b7] /opt/usr/local/lib/mylib.so(for__acquire_lun+0x814)[0x7ff92855ea04] /opt/usr/local/lib/mylib.so(for__acquire_lun+0x814)[0x7ff92855ea04] /opt/usr/local/lib/mylib.so(for_write_int_fmt+0x9c)[0x7ff92857f83c] /opt/usr/local/lib/mylib.so(for__acquire_lun+0x814)[0x7ff92855ea04] /opt/usr/local/lib/mylib.so(for_write_int_fmt+0x9c)[0x7ff92857f83c] /opt/usr/local/lib/mylib.so(seterr_+0x1c8)[0x7ff928515328] /opt/usr/local/lib/mylib.so(for_write_int_fmt+0x9c)[0x7ff92857f83c] /opt/usr/local/lib/mylib.so(seterr_+0x1c8)[0x7ff928515328] /opt/usr/local/lib/mylib.so(ddl2sf_+0x322)[0x7ff92850eb02] /opt/usr/local/lib/mylib.so(seterr_+0x1c8)[0x7ff928515328] /opt/usr/local/lib/mylib.so(entsrc_+0x80)[0x7ff92850edb0] /opt/usr/local/lib/mylib.so(bspline_+0x52c)[0x7ff92850d66c] /opt/usr/local/lib/mylib.so(ddl2sf_+0x2e7)[0x7ff92850eac7] /opt/usr/local/lib/mylib.so(enter_+0x55)[0x7ff92850ecd5] /opt/usr/local/lib/mylib.so(rspbsp_+0x4a)[0x7ff928523cda] /opt/usr/local/lib/mylib.so(bspline_+0x52c)[0x7ff92850d66c] /opt/usr/local/lib/mylib.so(ddl2sf_+0x16d)[0x7ff92850e94d] /tmp/jna--1845237309/jna4302334124297214663.tmp(ffi_call_unix64+0x4c)[0x7ff92909465c] /tmp/jna--1845237309/jna4302334124297214663.tmp(ffi_call+0x1d4)[0x7ff929094164] /opt/usr/local/lib/mylib.so(bspline_+0x52c)[0x7ff92850d66c] /opt/usr/local/lib/mylib.so(rspbsp_+0x4a)[0x7ff928523cda] /tmp/jna--1845237309/jna4302334124297214663.tmp(+0x5870)[0x7ff929087870] /tmp/jna--1845237309/jna4302334124297214663.tmp(java_com_sun_jna_native_invokevoid+0x22)[0x7ff92908a462] [0x7ffbb5015994]
afaik has native library not thread-safe? stacktracke seems me actual problem libc.so
, or own library mylib.so
?
case problem in own library, possible overcome problem making multiple physical copies of shared object, 1 each thread example?
this indicate issue in shared library or use. if did not design library thread-safe not. single process cannot load native library multiple times, there no easy solution in way. there couple of avenues:
- allocate multiple objects native library , different ones each java thread. may not possible if native library internally using static data structures.
- synchronize access native library via classes/methods expose it. in way single java thread access them @ time. however, depending on library , use case may not performance -- action still in 1 place.
- make library thread-safe. can lot more difficult in native languages java. additionally algorithms not suited parallelization.
Comments
Post a Comment