Open Almenon opened 6 years ago
I wrap excec in a try/catch BaseException, which is like the king 👑 of all try/catches. It will catch every possible exception no matter what. So I was confused as to why the segmentation fault generated by the numpy code didn't get caught by my kingly catch.
But apparently a segmentation fault is a signal (SIGSEGV) and signals ARE NOT caught by normal try/catches, as they are not technically exceptions. (even though they will happily crash your program just the same 💀)
In order to catch a signal you have to register a signal handler like so:
import os
import signal
def sig_handler(signum, frame):
print("segfault")
signal.signal(signal.SIGSEGV, sig_handler)
os.kill(os.getpid(), signal.SIGSEGV)
live demo: https://repl.it/@almenon/signal-handler-py3
This works great if you are on ubuntu .... not so great if you are on windows. In fact, this does not work at all on windows!
upgrading jsonpickle should have solved the issue but the process still crashes :/ I guess I should raise a bug in jsonpickle repo
This still causes AREPL to crash, but at least there's a indicator now:
Error in the AREPL extension!
err code: 3221225477
python 3.12, numpy==2.1.3. I had to change np.object
to object
to fix a deprecation exception,
The error happens on the second run.
This will be fixed by https://github.com/Almenon/AREPL-vscode/issues/439
This code causes arepl to hang indefinitely without giving any visual indicator that it crashed.
Opening up the dev console I see the following error: