Skip to content

network: look devices up without inserting null entries - #598

Open
abdelhaleemahmed wants to merge 1 commit into
WayfireWM:masterfrom
abdelhaleemahmed:network-null-device
Open

abdelhaleemahmed wants to merge 1 commit into
WayfireWM:masterfrom
abdelhaleemahmed:network-null-device

Conversation

@abdelhaleemahmed

Copy link
Copy Markdown

Fixes the start-up crash with the backtrace in #495 (NetworkControlWidget::add_device() called with an empty std::shared_ptr<Network>).

std::map::operator[] inserts an empty shared_ptr for a missing key. get_connection() can list a device while add_network() is still creating its D-Bus proxy asynchronously; the empty entry it inserts makes the emplace() in the proxy callback a no-op, and device_added then emits the empty pointer, which add_device() dereferences. (If the lookup comes before add_network() runs for that device, the empty entry makes add_network() skip the device as already known.) It depends on timing, which matches the reports that the crash comes and goes and does not happen under gdb.

The fix: a small find_device() helper that looks up without inserting, used in get_connection(), DeviceRemoved, request_password() and submit_password(). The places that create devices are unchanged; with no empty entries in the map their emplace() works again.

I hit this crash on Rocky Linux 10 (wf-shell 0.11.0) at every login. The same fix, applied to 0.11.0, has run there since without a crash. On master I checked that manager.cpp builds without warnings and passes uncrustify; I could not run master's panel there, because it needs a newer gtkmm than the distribution has.

🤖 Generated with Claude Code

std::map::operator[] inserts an empty shared_ptr for a missing
key. get_connection() can list a device while add_network() is still
creating its D-Bus proxy asynchronously. The empty entry it inserts
makes the emplace() in the proxy callback a no-op, and device_added
then emits the empty pointer: NetworkControlWidget::add_device() calls
get_path() on it and wf-panel crashes at start-up (the backtrace in
WayfireWM#495). A device looked up before add_network() runs for it is skipped
as already known for the same reason.

Look devices up with find() in get_connection(), DeviceRemoved,
request_password() and submit_password().

See WayfireWM#495.

Co-Authored-By: Claude Opus 5.5 <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.

1 participant