Skip to content

Conversation

@little-big-h
Copy link

I've run into this problem (when building a libclang-based emacs plugin): when calling a function from a callback, the (global) environment pointer is nulled out after the function call (but before finishing the callback). This causes an assertion to fail and crashes emacs.

I see that this is tricky to handle due to the poorly designed emacs runtime (see aaptel/emacs-dynamic-module#41). I have some ideas how to fix/hack it (e.g., a map of function calls to environment objects) and would be willing to help. I felt that this starts with contributing a test case :-).

(ert-deftest ffi-call-callback-with-ffi-add-call ()
(let* ((cif (ffi--prep-cif :int [:int]))
(pointer-to-callback (ffi-make-closure cif #'callback-with-ffi-add-call)))
(should (eq (test-call-callback pointer-to-callback) "hello"))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is strange here, because test-call-callback is going to return an integer, but this test is checking to see if it is eq to a string -- which can't happen.

When I change this to expect 23, it works locally.

I wouldn't doubt that there is a problem -- that issue you pointed at has never been fixed -- but I think some other test case is required to show it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants