JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
722 stars 61 forks source link

Segfaults when printing strings that have python values #342

Closed untoreh closed 11 months ago

untoreh commented 11 months ago

Describe the bug I have stumbled on many cases where when there is code that is trying to create a string with interpolated python values in it, a segfault can happen.

I don't have a clear way to reproduce the issue, this a stack trace when it happens, trying to log an exception:

XXX lineno: 85, opcode: 150

[20931] signal (11.1): Segmentation fault
in expression starting at none:0
PyEval_GetGlobals at /usr/local/src/conda/python-3.11.4/Python/ceval.c:7204 [inlined]
PyImport_Import at /usr/local/src/conda/python-3.11.4/Python/import.c:1990
PyImport_Import at /home/fra/.julia/packages/PythonCall/1f5yE/src/cpython/pointers.jl:299 [inlined]
macro expansion at /home/fra/.julia/packages/PythonCall/1f5yE/src/Py.jl:131 [inlined]
pyimport at /home/fra/.julia/packages/PythonCall/1f5yE/src/concrete/import.jl:11
#_showerror#13 at /home/fra/.julia/packages/PythonCall/1f5yE/src/err.jl:126
_showerror at /home/fra/.julia/packages/PythonCall/1f5yE/src/err.jl:113 [inlined]
showerror at /home/fra/.julia/packages/PythonCall/1f5yE/src/err.jl:109 [inlined]

Your system Please provide detailed information about your system: Julia Version 1.9.2 Commit e4ee485e909 (2023-07-05 09:39 UTC) Platform Info: OS: Linux (x86_64-linux-gnu)

cjdoris commented 11 months ago

It's hard to say much without code that can reproduce the error - please try to figure out a minimal way to make this problem occur.

untoreh commented 11 months ago

Some possible causes (not sure if they can actually happen though):

I don't think these are solvable or caused by pythoncall