numba: Program crashes with ACCESS_VIOLATION. Windows only.
Reporting a bug
>>> import numba
>>> numba.__version__
'0.53.0'
This bug was tested on different Python versions (3.7, 3.9) and different numba versions (0.45.0, 0.53.0, 0.50.0)
I am using package called librosa which depends on resampy which utilizes numba. Also I am using native Csound library using ctype bindings.
Whenever I am trying to run JITed code program crashes (resampy.interp.resample_f). If I disable JIT compilation by NUMBA_DISABLE_JIT=1 program works fine. If I remove Csound or librosa programs work fine as well. Bug is Windows only reproducable.
Here is bug reproduce steps:
- Download latest csound version
- Copy
ctcsound.pybinding fromcsound/binfolder tosite-packagesor tobug.pyfile location - Place any
.wavfile overbug.py - Run following code:
import ctcsound
import librosa
if __name__ == "__main__":
ct = ctcsound.Csound()
audio, orig_sr = librosa.load("some_sample.wav", sr=None)
audio = librosa.resample(audio, orig_sr, 44020)
print("NOT CRASHED!")
Program crashes with 0xC0000005 error (ACCESS_VIOLATION). Debugger screenshot
It seems that it’s trying to dereference [[_PyThreadState_Current]+0x48], but because [_PyThreadState_Current] is 0 next instruction getting 0x48. 0x48 is outside of virtual memory map that why we are getting 0xC0000005. I think it’s something about GIL.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 35 (15 by maintainers)
I put together the following script to show the addresses of all instances of
Py_IsInitialized(a CPython symbol) and what LLVM is seeing:The
libpy_checkis available at https://gist.github.com/sklam/4837581ff47ba72c0ee9678e1aebe1c7.The output of the script is:
This confirms that the line
ct = ctcsound.Csound()is loading apython27.dllinto memory. From that point on, LLVM is seeingPy_IsInitializedfrom thepython27.dllinstead from thepython38.dll.A related note from LLVM at: https://github.com/llvm/llvm-project/blob/62ec4ac90738a5f2d209ed28c822223e58aaaeb7/llvm/lib/Support/Windows/DynamicLibrary.inc#L136-L140 is indicating that the symbol search order is reversed on win32. On Unix, it searches from the oldest to newest. On Win32, it searches from newest to oldest. That explains why this is a windows only problem.
It is still odd that a process can have symbols with duplicated names. How do one tell which dll module is the current interpreter? Can a process have multiple python dll modules of the same version?
I think the reason of the issue is found, so you can close issue, but you can create new one exactly for that case.
@rawwar some people have that issue, some don’t. I really have no clue what is the reason. I have this script working on my laptop, but on PC it’s crashes.
Running into the same crash as @Redict using Python 3.7 and both numba 0.43/0.53