You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you don't remember to call UnregisterForSystemEvent after registering a shutdown handler, when the kernel is shutdown you get a segfault. Here's a sample in Python, but I also did it in Tcl. Originally I was looking into why we had to have a special atexit handler in the Python SML test script in the past, and I whittled down to this MBE; I don't really see how an atexit handler that shuts down the kernel would help here, though, so it might be a separate issue.
try:
fromPython_sml_ClientInterfaceimport*exceptImportError:
fromsoar_smlimport*# also fails# kernel = Kernel.CreateKernelInNewThread()kernel=Kernel.CreateKernelInCurrentThread()
shutdownCallbackId=kernel.RegisterForSystemEvent(smlEVENT_BEFORE_SHUTDOWN, lambda: 1+1, None)
# Fixes the segfault!# kernel.UnregisterForSystemEvent(shutdownCallbackId)print("shutting down kernel")
# segfaultskernel.Shutdown()
# never printsprint("deleting kernel")
delkernelprint("finished")
The text was updated successfully, but these errors were encountered:
Previous behavior here was to segfault! An exception is much more user-friendly.
Add the SWIG machinery for catching thrown exceptions in the SML binding
libraries, too. We wrap every SML function with a try/catch. I don't know if
this is actually heavy or not, but at least one implementation out there thought
it was and went an alternative route where each method has to be explicitly
marked to catch exceptions:
https://github.com/KiCad/kicad-source-mirror/blob/47e4ebb32a1366d60649879381eac819f7c7131d/common/swig/ki_exception.i#L41
Add tests for TCL, Python and Java that demonstrate the exceptions being
translated for each host language. We don't have C# tests yet T_T.
Notice we did have to add the `atexit` handler back to prevent a segfault when
the exception is not caught correctly; I don't know exactly why. Filed #464.
Fixes#451.
If you don't remember to call
UnregisterForSystemEvent
after registering a shutdown handler, when the kernel is shutdown you get a segfault. Here's a sample in Python, but I also did it in Tcl. Originally I was looking into why we had to have a specialatexit
handler in the Python SML test script in the past, and I whittled down to this MBE; I don't really see how anatexit
handler that shuts down the kernel would help here, though, so it might be a separate issue.The text was updated successfully, but these errors were encountered: