-
Notifications
You must be signed in to change notification settings - Fork 761
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
fatal runtime error: failed to initiate panic, error 5 #766
Comments
If anyone knows what might cause this or how to debug or find a workaround I would love to know! This bug makes it impossible for me to use PyO3/maturin for any serious project, which is a shame since I've found PyO3/maturin it to be incredibly useful in all other respects. |
@davidhewitt Thanks for your response, this makes a lot more sense to me now! Inserting (Curiously, when I ran my repro under WSL the files and line numbers always display even without the |
That's because Rust currently uses the same unwind mechanism as C/C++ on x86_64 Linux. It's still undefined behavior because Rust doesn't define that it's supposed to work, it just happens to work anyway. |
Thanks, good to know that addressing #492 will fix this! |
Unfortunately, while catch_unwind prevents the runtime error, it does not actually fix the missing line numbers (at least on Mac). I have been debugging the problem further, and managed to narrow down the issue by reproducing the same failure with a minimal cffi setup that uses neither PyO3 or maturin. The root of the problem seems to be that (at least on mac) the
When loading I am still working on proving this out further by constructing a pip wheel with the symbol file included, so far it's still crashing on pip install (I think I managed to properly adjust the RECORD but I must be missing something else). Provided people agree that including those files in the wheel is the correct solution I could use some help with making the necessary changes to maturin. I suspect we are failing to include similar symbol files under Linux but this remains to be tested. |
I figured out how to create the pip wheel and after installation the site-packages seem to have the right structure, but backtraces are still broken so there must be another missing piece. |
The example I have where backtraces work loads the dll with
How does the equivalent code in PyO3/maturin work? |
Not sure what I was doing wrong before, but after copying the dlyb and DWARF folder into the site-packages directory I have backtraces working correctly for PyO3/maturin under Mac. Will now try to reproduce the issue I saw under Linux, which I'm now thinking might actually be a separate problem. |
So turns out the original problem I ran into was actually caused by running out of file descriptors and is unrelated to PyO3. There are already separate issues to track the unwinding and missing DWARF files on Mac so this issue can be closed now. |
Awesome. Thanks so much for all the detailed investigation! |
🐛 Bug Reports
Pip packages generated with PyO3 and maturin fail to generate full backtraces on panic which makes it extremely difficult to debug crashes in published packages.
Only the initial stack frame in the backtrace displays a file and line number, file and line number are missing on all other frames.
Notably, this error is printed out as well which seems to indicate a serious issue with the panic handler:
fatal runtime error: failed to initiate panic, error 5
This seems vaguely related: rust-lang/rust#35599
Under some conditions, the backtrace also displays
<unknown>
instead of any symbols but I don't have a minimal reproduction for this and it might well be caused by a different issue.See https://github.com/cswinter/pyo3-backtrace-repro for a minimal reproduction.
Example output:
🌍 Environment
OS: MacOS 10.14.6. Also observed under Ubuntu.
PyO3 version:
0.9.0-alpha.1
,0.8.3
maturin version:
0.7.7
Python:
Python 3.8.0
via conda. Also observed under virtualenv.The text was updated successfully, but these errors were encountered: