Skip to content

Fixes a segfault with callbacks seen on Ubuntu 26#391

Merged
romgrk merged 2 commits into
romgrk:masterfrom
chfritz:Issue#390_segfault_in_callback_ubuntu26
May 30, 2026
Merged

Fixes a segfault with callbacks seen on Ubuntu 26#391
romgrk merged 2 commits into
romgrk:masterfrom
chfritz:Issue#390_segfault_in_callback_ubuntu26

Conversation

@chfritz

@chfritz chfritz commented May 30, 2026

Copy link
Copy Markdown
Contributor

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.

chfritz added 2 commits May 29, 2026 17:10
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.
@romgrk romgrk merged commit c5d6ec6 into romgrk:master May 30, 2026
6 of 9 checks passed
@chfritz chfritz mentioned this pull request May 31, 2026
romgrk added a commit that referenced this pull request Jun 1, 2026
…393)

* Revert "Fixes a segfault with callbacks seen on Ubuntu 26 (#391)"

This reverts commit c5d6ec6.

* Restore test updates from reverted callback fix

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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>
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.

Segfault when using callbacks in Ubuntu 26.04

2 participants