Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RocksJava Crashes when compiled with jemalloc on MacOS #5787

Open
adamretter opened this issue Sep 10, 2019 · 2 comments
Open

RocksJava Crashes when compiled with jemalloc on MacOS #5787

adamretter opened this issue Sep 10, 2019 · 2 comments
Labels
bug Confirmed RocksDB bugs mac

Comments

@adamretter
Copy link
Collaborator

I guess this is the follow on issue from #2954

After compiling RocksDB (today's git HEAD of master) on MacOS, if you run make jtest then you get a SIGSEGV in a call to jemalloc.

  • macOS Mojave - 10.14.5
  • Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  • Oracle JDK 1.7.0_80-b15 64-Bit Server VM
  • jemalloc 5.2.1 (installed via homebrew)

The jtest suite appears to complete successfully, but then we get the SIGSEGV:

Time: 133.129

OK (883 tests)

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001201a7f6c, pid=18203, tid=9987
#
# JRE version: Java(TM) SE Runtime Environment (7.0_80-b15) (build 1.7.0_80-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.80-b11 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libjemalloc.2.dylib+0x6f6c]  je_free_default+0xab
#

The Java error report stack looks like (full stack attached - hs_err_pid18203.log):

Stack: [0x000070000d9c5000,0x000070000dac5000],  sp=0x000070000dac4c00,  free space=1023k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libjemalloc.2.dylib+0x6f6c]  je_free_default+0xab
C  [libjemalloc.2.dylib+0x44c5a]  zone_free+0xaf
C  [CoreFoundation+0x13c9af]  _CFRelease+0x2c0
C  [SystemConfiguration+0x6a27]  __SCThreadSpecificDataFinalize+0x2a
C  [libsystem_pthread.dylib+0x3660]  _pthread_tsd_cleanup+0x1dc
C  [libsystem_pthread.dylib+0x6655]  _pthread_exit+0x46
C  [libsystem_pthread.dylib+0x32f6]  _pthread_body+0x89
C  [libsystem_pthread.dylib+0x6249]  _pthread_start+0x42
C  [libsystem_pthread.dylib+0x240d]  thread_start+0xd
@adamretter adamretter added bug Confirmed RocksDB bugs mac labels Sep 10, 2019
@ltamasi
Copy link
Contributor

ltamasi commented Sep 12, 2019

I suspect this is caused by the JVM using the stock allocator, and the native code using jemalloc. One workaround I found is to force the JVM to use jemalloc as well; on Mac, this can be done by setting the environment variable DYLD_INSERT_LIBRARIES on the command line, e.g.:

DYLD_INSERT_LIBRARIES=/usr/local/lib/libjemalloc.2.dylib java -ea -Xcheck:jni -Djava.library.path=target -cp target/classes:samples/target/classes RocksDBSample /tmp/rocksdbjni

Note: this is the equivalent of using LD_PRELOAD on Linux. It solved the issue for me.

@adamretter
Copy link
Collaborator Author

For building RocksDB I also added the option ROCKSDB_DISABLE_JEMALLOC=true which will disable its auto-detection of jemalloc.

@adamretter adamretter changed the title RocksDB Crashes when compiled with jemalloc on MacOS RocksJava Crashes when compiled with jemalloc on MacOS Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed RocksDB bugs mac
Projects
None yet
Development

No branches or pull requests

2 participants