Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

start_jvm: kill -TERM crashes the process (SIGSEGV in JPype's TERM handler), and the docs say it runs the shutdown hooks #185

Closed

Description

@tae898

With interrupt=False (the default since #133), kill -TERM on a Python process that started the JVM through the bindings crashes it instead of running the JVM's shutdown hooks. The JVM's "SIGTERM handler" thread, JPype's TERM handler, calls PyErr_SetInterruptEx without the GIL and hits SIGSEGV in PyObject_RichCompareBool: exit status -6 and ./log/hs_err_pid*.log written. It reproduced 4 out of 4 times, with a JVM only 0.5 s old and no databases, found while fixing #179.

A Python signal.signal(SIGTERM, handler) registered after start_jvm avoids the crash (the handler runs, exit 0).

The sentence "kill -TERM ... ends the process at once, through the JVM's shutdown hooks" in docs/api/jvm.md and in the start_jvm docstring is wrong as written. Needs: a reproduction test (start the JVM, send SIGTERM, assert a clean exit and no hs_err file), the fix (register a Python SIGTERM handler in start_jvm, or document the crash and the workaround), and the doc sentences corrected. The root cause is in JPype 1.7.1, so also a JPype issue (not filed yet).

Activity

  1. tae898 commented on Oct 10, 2026

    @tae898
    Author

    The crash is JPype's: its TERM handler calls PyErr_SetInterruptEx without the GIL (tracked at jpype-project/jpype#1497). What was ours was the docs saying the shutdown hooks run, and #200 fixed that: the known-issues page now documents the SIGTERM crash with its workaround. Nothing else is actionable here until JPype fixes it, so closing; reopen if it still crashes after a JPype release that claims the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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