Skip to content

fix(all): Fix two segfault bugs in map.lic#2232

Closed
MahtraDR wants to merge 3 commits intoelanthia-online:masterfrom
MahtraDR:fix/map-gtk-bugs
Closed

fix(all): Fix two segfault bugs in map.lic#2232
MahtraDR wants to merge 3 commits intoelanthia-online:masterfrom
MahtraDR:fix/map-gtk-bugs

Conversation

@MahtraDR
Copy link
Contributor

@MahtraDR MahtraDR commented Feb 4, 2026

Fix GTK3 bugs in map.lic: borderless toggle crash and macOS teardown segfault

Summary

  • Fix borderless toggle crash caused by compound expression in set_decorated call
  • Fix potential macOS Quartz segfault on script kill by hiding image widgets before window destruction

Bug 1: Borderless toggle crash

Line 697 — The toggled signal handler uses a compound expression:

window.set_decorated(!setting_borderless = owner.active?)

This passes the result of an inline assignment through negation into set_decorated, which crashes gobject-introspection's invoke on some platforms. The Ruby expression is valid, but the GObject binding chokes on the intermediate value.

Fix: Split into two statements:

setting_borderless = owner.active?
window.set_decorated(!setting_borderless)

Bug 2: macOS Quartz segfault on script kill

Lines 1126-1129 — The before_dying block destroys the window without first detaching its Cairo-backed child widgets:

Gtk.queue {
  menu.destroy
  window.destroy
}

On macOS with GTK3's Quartz backend, this can segfault in _gdk_quartz_unref_cairo_surface during surface teardown. The crash occurs because the Gtk::Image widgets (image, circle_image) still hold references to Cairo surfaces when the parent window is destroyed.

Fix: Hide the image widgets before destroying the window:

Gtk.queue {
  image.hide
  circle_image.hide
  menu.destroy
  window.destroy
}

Test plan

  • Toggle borderless mode on/off via right-click menu — no crash
  • Kill the map script (;kill map) — no segfault
  • Close the map window via window close button — no segfault
  • Verify map displays correctly after toggling borderless mode

Important

Fixes two segfault issues in map.lic related to GTK3: borderless toggle crash and macOS teardown segfault.

  • Bug Fixes:
    • Fix borderless toggle crash in map.lic by splitting compound expression in menu_borderless.signal_connect.
    • Fix macOS Quartz segfault in before_dying block by hiding image and circle_image before window destruction.
  • Test Plan:
    • Toggle borderless mode without crashing.
    • Kill the map script without segfaulting.
    • Close the map window without segfaulting.
    • Verify map displays correctly after toggling borderless mode.

This description was created by Ellipsis for 005e9bf. You can customize this summary. It will automatically update as commits are pushed.

…segfault

1. Borderless toggle: split compound expression
   `window.set_decorated(!setting_borderless = owner.active?)` into two
   statements. The compound form passes a complex Ruby expression through
   gobject-introspection's invoke, which crashes on some platforms.

2. before_dying cleanup: hide image and circle_image widgets before
   destroying the window. On macOS with GTK3/Quartz backend, destroying
   the window while Cairo-backed image widgets are still visible causes a
   segfault in _gdk_quartz_unref_cairo_surface during surface teardown.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 005e9bf in 9 seconds. Click for details.
  • Reviewed 27 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_Gcaj2UPBAYsCdE7N

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

MahtraDR and others added 2 commits February 4, 2026 13:34
Tests verify:
- Borderless toggle: setting_borderless and set_decorated are called
  as separate operations with plain boolean arguments
- before_dying cleanup: image widgets are hidden before any destroy
  calls, enforcing the order that prevents macOS Quartz segfaults

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mrhoribu
Copy link
Contributor

mrhoribu commented Feb 4, 2026

Both issues resolved in #2207 update

@mrhoribu mrhoribu closed this Feb 4, 2026
@MahtraDR MahtraDR deleted the fix/map-gtk-bugs branch February 4, 2026 02:17
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