Fixes a segfault with callbacks seen on Ubuntu 26#391
Merged
romgrk merged 2 commits intoMay 30, 2026
Conversation
Fixes romgrk#390. Disclaimer: I used Claude to debug this. Claude failed twice but then got on the right path when I ran gdb and pin-pointed the line in function.cc where it happens. It then produced a patch that was much to large, including all its failed attempts before. Those changes may still have merit, but they weren't essential for fixing this, so I narrowed it down to what appears the essential change. Tested with both reported cases, which now work.
- needed in Ubuntu 26
Merged
romgrk
added a commit
that referenced
this pull request
Jun 14, 2026
On libffi 3.4+ the executable trampoline is a separate memory mapping from the writable ffi_closure, so the closure pointer itself is not callable; passing it to C as the callback function pointer segfaults when the callback fires. This is reproducible on Ubuntu 26 (libffi 3.5) and matches the `node examples/glib-timeout.js` crash in the report. Pass g_callable_info_get_closure_native_address() instead of the raw closure. This re-applies #391, which was reverted in #393 because it broke startup — guarded here by falling back to the closure pointer when introspection returns NULL, so a callback pointer is never NULL at bootstrap. On platforms where the two addresses coincide (older libffi, or where the closure is already executable) the behavior is unchanged. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #390.
Disclaimer: I used Claude to debug this. Claude failed twice but then got on the right path when I ran gdb and pin-pointed the line in function.cc where it happens. It then produced a patch that was much to large, including all its failed attempts before. Those changes may still have merit, but they weren't essential for fixing this, so I narrowed it down to what appears the essential change.
Tested with both reported cases, which now work.
PS: also updated the test cases to use the newly required parameter for
Gst.init.