fusesource / leveldbjni

A Java Native Interface to LevelDB
BSD 3-Clause "New" or "Revised" License
536 stars 143 forks source link

SIGSEGV on JVM termination #36

Open mt256 opened 11 years ago

mt256 commented 11 years ago

I am writing a program that uses several LevelDB databases (some of them in different threads). Everything works as expected but after the main method finishes execution and the JVM starts to shut down I get this:

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x00007fd24b1e0ea8, pid=12289, tid=140541201016576

JRE version: 7.0_21-b02 Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops) Problematic frame: V [libjvm.so+0x6b2ea8] Monitor::ILock(Thread*) [clone .part.73]+0x18

cardamon commented 10 years ago

I can confirm this issue and may be able to offer some insight as to what the problem might be... The problem goes away if the opening and closing of databases and the pushing and popping of the mem pools are done by the SAME thread.

So if this:

DB db = factory.open(new File("example"), options);
JniDBFactory.pushMemoryPool(1024 * 512);

and this:

db.close();
JniDBFactory.popMemoryPool();

are done by different threads, the JVM will crash with the indicated problematic frame. I do not know if this only happens under specific circumstances...

Just doing this on the same thread might be a workaround for now.

chirino commented 10 years ago

Yep thats to be expected. The push/pop has to occur in the same thread. Perhaps we should do some more active checking of that.

On Thu, Dec 12, 2013 at 4:54 AM, cardamon notifications@github.com wrote:

I can confirm this issue and may be able to offer some insight as to what the problem might be... The problem goes away if the opening and closing of databases and the pushing and popping of the mem pools are done by the SAME thread.

So if this:

DB db = factory.open(new File("example"), options);JniDBFactory.pushMemoryPool(1024 * 512);

and this:

db.close();JniDBFactory.popMemoryPool();

are done by different threads, the JVM will crash with the indicated problematic frame. I do not know if this only happens under specific circumstances...

Just doing this on the same thread might be a workaround for now.

— Reply to this email directly or view it on GitHubhttps://github.com/fusesource/leveldbjni/issues/36#issuecomment-30402658 .

Hiram Chirino

Engineering | Red Hat, Inc.

hchirino@redhat.com hchirino@redhat.com | fusesource.com http://fusesource.com | redhat.com http://redhat.com/

skype: hiramchirino | twitter: @hiramchirino http://twitter.com/hiramchirino

blog: Hiram Chirino's Bit Mojo http://hiramchirino.com/blog/

smreed commented 10 years ago

I am seeing the same SIGSEGV despite opening and closing my db on the same thread.

Turns out, using my own logger was the culprit.

public static void main(String[] args) throws IOException {
  Options options = new Options();
  options.logger(new Logger() {
    @Override
    public void log(String message) {
      System.out.print(message);
    }
  });
  DB db = JniDBFactory.factory.open(new File("/tmp/logger-sigsegv"), options);
  db.close();
}
matthewrj commented 8 years ago

I experienced the same problem. Removing the logger fixed it.

tnatraj commented 7 years ago

I were facing same problem while using logger, But i want to use logger, help me to fix this issue.