-
Notifications
You must be signed in to change notification settings - Fork 70
Segmentation fault when calling basic python functions #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the detailed report and the reproducer. I believe I have fixed it in #618 - please give it a try with your MWE and your actual problem. The specific offending line appears to be PythonCall.jl/src/Core/builtins.jl Line 897 in 0a7d49f
incref(getptr(Py(x))) it's possible that Julia frees Py(x) before incref(getptr(...)) is called, and so the underlying Python object would be decref'd and freed, invalidating the pointer from getptr(...) .
|
PS the reproducer made my laptop very warm thank you 😄 |
We have a python application calling julia multithreaded code. Our stress test takes 7h, and before this MR it crashed with all julia versions afters 1.10.7. With it, it's not crashing anymore. You made my day 🙏 |
Thank you very much for this prompt fix!! I have tested my MWE and some real examples and so far it seems to fix the issue! |
Fwiw, #618 also seems to fix #563 for me (or at least what seemed like a very similar issue to me ) |
Uh oh!
There was an error while loading. Please reload this page.
Affects: PythonCall
Describe the bug
I get segmentation faults when using PythonCall to call python functions that create python objects many times. It does not happen deterministically, but happens (on a couple of systems I have tested it on) reliably for the MWE below:
Sometimes I get the segmentation fault immediately, before the first print statement, sometimes 30% of the loop succedes before the segfault.
If I wrap the doubles in
Py
objects explicitly before, I do not get segmentation faults:My understanding is that this shouldn't be necessary to deal with explicitly, but somehow it is in this example. And since this is only a MWE it is not a solution to my actual problem, since I do not know which calls / arguments need this explicit handling and which do not.
Here is the segfault output (from the first code snippet):
Your system
Please provide detailed information about your system:
Additional context
The actual context where this happened to me is that I am using PythonCall.jl to use the python interface of the lanelet2 library, which in turn is a boost python interface to C++ code. I am getting segmentation faults from a couple of calls to this library.
The text was updated successfully, but these errors were encountered: