Skip to content
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

added a (crashing) test that calls an ffi-function from a callback #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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