Skip to content

JVM crash Session causes SIGSEGV/SIGBUS under repeated use of Session.create() #8075

@dfa1

Description

@dfa1

What happened?

There is a reproducer of the issue in
https://github.com/dfa1/datastore — a benchmark comparing CSV / JSON / Parquet / Vortex storage formats.

  git clone https://github.com/dfa1/datastore.git
  cd datastore
  mvn test -Dtest="ReadColumnTest,VortexOhlcStoreTest"  # passes (few iterations)
  mvn test -Dtest="BenchmarkTest"                        # crashes (84+ Vortex ops)

BenchmarkTest runs 7 scales × (2 warmup + 10 measured) iterations × 3 operations (write / read /
readColumn) = 252 Session objects created in one JVM process.

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001393da064, pid=71272, tid=5635
#
# JRE version: OpenJDK Runtime Environment (27.0+1) (build 27-jep401ea3+1-1)
# Java VM: OpenJDK 64-Bit Server VM (27-jep401ea3+1-1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C  [libvortex_jni9112159322116037794.dylib+0x32064]  vortex_file::writer::WriteOptionsSessionExt::write_options::h986f424532314d6f+0x18
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

Possible fix:

Make Session implement AutoCloseable and expose the Cleanable so callers can release native deterministically:

  public final class Session implements AutoCloseable {
      private final Cleaner.Cleanable cleanable;

      private Session(long pointer) {
          Preconditions.checkArgument(pointer != 0, "invalid session pointer");
          this.pointer   = pointer;
          this.cleanable = VortexCleaner.register(this, () -> NativeSession.free(pointer));
      }

      @Override
      public void close() {
          cleanable.clean(); // idempotent — safe to call; Cleaner won't double-free
      }
  }

Callers could then write:

  try (Session session = Session.create()) {
      // ...
  }

Steps to reproduce

see the attached instructions above

Environment

  • vortex-jni version: 0.72.0
  • JDK 27 EA (Homebrew, aarch64 macOS): crashes ✗ — SIGSEGV/SIGBUS under repeated Session use
  • Arch: bsd-aarch64

Additional context

I got the error also once in JDK 25 but it is much harder to reproduce.
The proposed fix is the idiomatic way in Java to deal with external resources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions