jpype
jpype copied to clipboard
Rare crashes on interpreter exit
Hi, I am using JPype in a pytest context to execute SQL commands on an oracle database via JayDeBeApi. And I am experiencing segfaults of the python interpreter in less than 1% of the cases after the testrun finishes.
I set up a minimal test that just connects to the database and disconnects again with an execution time of ~5 seconds, which allows me to reproduce this bug fairly quickly in a loop.
Unfortunately no python backtrace is printed and the generated coredump does not seem to yield a valid stacktrace, so maybe the bug is related to memory corruption? Note that I can fix/work around it by calling jpype.shutdownJVM() manually, but my understanding was that this should not be necessary, correct?
Is there anything I can do to analyze this issue so this could be fixed properly?
Sounds very similar to https://github.com/jpype-project/jpype/issues/934. It has been a while since I last looked at that issue, and since then https://github.com/jpype-project/jpype/pull/937 has been merged. In principle, I think at least the segfault may be avoidable by setting jpype.config.free_resources = True before exiting. For example, you could do this as a pytest fixture (e.g. with autouse=True).
Perhaps you could try setting that config to see if it resolves the issue.