Skip to content

Instantly share code, notes, and snippets.

@Lovesan
Created June 6, 2019 21:45
Show Gist options
  • Save Lovesan/eff406bb0201af74371248b59c246a92 to your computer and use it in GitHub Desktop.
Save Lovesan/eff406bb0201af74371248b59c246a92 to your computer and use it in GitHub Desktop.
SBCL code for testing cross-boundary exceptions
(sb-alien:load-shared-object "unwind.dll")
(sb-alien:define-alien-routine
("catches_fn" catches-fn)
sb-alien:void
(fn (* T)))
(defun sap-to-callable (ptr)
(sb-alien:sap-alien
(sb-alien:alien-sap ptr)
(function sb-alien:void)))
(sb-ext:defglobal
alien-callback
(sb-alien:alien-sap
(sb-alien::alien-lambda sb-alien:void ((ptr (* t)))
(format *error-output* "Lisp callback~%")
(unwind-protect (sb-alien:alien-funcall (sap-to-callable ptr))
(format *error-output* "Lisp unwind")))))
(defun test-seh ()
(catches-fn alien-callback)
(values))
(test-seh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment