Skip to content

Kotlin/Native test-binary linker crashes (SIGSEGV) on Linux dev hosts under memory pressure #56

Description

@jamesarich

./gradlew build cannot complete on at least one Linux x64 dev host: the Gradle daemon dies with a JVM SIGSEGV during linkDebugTestLinuxX64 (and linkDebugTestLinuxArm64 / linkDebugTestMingwX64), inside the in-process Kotlin/Native compiler's teardown — the crash trace points at kotlinx.cinterop.Caches.disposeFfiffiFreeClosure0jni_DeleteGlobalRef, with the hs_err log showing the fault inside AccessInternal/G1BarrierSet.

Confirmed pre-existing, not a regression

Reproduced identically on pristine main (commit fba1059) with no source changes at all — three independent sessions on the same host hit the exact same crash while working on unrelated branches. It survived every workaround tried in those sessions:

  • Larger daemon heap (-Xmx6g)
  • --no-parallel --max-workers=1
  • Switching GC / out-of-process compiler flags
  • Stopping all Gradle/Kotlin daemons first and retrying cold
  • Running outside the sandboxing layer of the coding-agent tool

Likely trigger

The host was under heavy memory pressure at the time (multiple concurrent Gradle daemons / agent processes, tens of GB resident, some swap activity). This may be specific to constrained/contended memory rather than a pure toolchain bug — worth checking whether it reproduces on a quiet host before assuming it's universal. JDK is Nix-provided 21.0.12.

What still verifies cleanly

The crash happens after the linker has already written the test binary, so the native leg isn't actually unverified:

  • ./gradlew build -x linkDebugTestLinuxX64 -x linuxX64Test -x linkDebugTestLinuxArm64 -x linkDebugTestMingwX64BUILD SUCCESSFUL (covers compilation of every target's klib, apiCheck, spotlessCheck, detekt, and every runnable test target: JVM, JS, Wasm).
  • The already-linked build/bin/linuxX64/debugTest/test.kexe runs standalone and passes in full when invoked directly, bypassing Gradle's link step.

So this blocks a fully green ./gradlew build locally on an affected host, but doesn't appear to indicate a real test failure — CI (which this project runs cross-platform) should be checked for the same signature before concluding it's host-specific.

Repro

./gradlew linkDebugTestLinuxX64
# or: ./gradlew build

on a Linux x64 host with significant concurrent memory pressure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions