wasmer-java icon indicating copy to clipboard operation
wasmer-java copied to clipboard

JVM fails with core dump

Open melix opened this issue 4 years ago • 2 comments

Describe the bug

Invocation of a WASM binary triggers a segfault in the VM, crashing it. It seems that this occurs quite frequently on my laptop, but I'm seeing successful runs also.

An example of a failing run: https://scans.gradle.com/s/d7otkguc6enr6/console-log?anchor=73 Without any code change, this one passed: https://scans.gradle.com/s/cqx4p4rdmfdf2

Steps to reproduce

Pre-requisites: install cargo and cargo install wasm-gc.

  1. Clone https://github.com/melix/gradle-wasm-plugin
  2. git chechout jvm-crash
  3. Run ./gradlew functionalTest
  4. See error (or not)

Expected behavior

The JVM shouldn't crash.

Actual behavior

The JVM crashes more often than it should.

Additional context

This behavior was observed under Linux Mint 20.1. I have attached a core dump.

hs_err_pid1026074.log

The problem seems to occur during finalization. It's worth noting that you shouldn't rely on finalize in Java.

Seems that commenting out the instance.close() call on https://github.com/melix/gradle-wasm-plugin/blob/2ff26beb103c8049e7215084852d7dbbde889870/wasm-base-tasks/src/main/java/me/champeau/gradle/wasm/tasks/AbstractWasmTask.java#L49 fixes the pb.

melix avatar Feb 13 '21 17:02 melix

Thank you for the detailed report! It looks a duplicated issue of https://github.com/wasmerio/wasmer-java/issues/58. I'll investigate :-).

Hywan avatar Mar 02 '21 12:03 Hywan

I can confirm that not calling instance.close() definitely improves stability. Calling it resulted in my JVM crashing without fail every time after a couple of invocations.

johnkbarrow avatar Aug 23 '21 15:08 johnkbarrow