Skip to content

Commit

Permalink
#2210 fix rare crash that could occur on application termination
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Apr 4, 2024
1 parent 8c021a4 commit 488671e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Properly escape app and title, role and subrole, regex when listing rules [#2205](https://github.com/koekeishiya/yabai/issues/2205)
- Properly escape app and title regex when listing signals [#2207](https://github.com/koekeishiya/yabai/issues/2207)
- Fixed issue that could cause a crash when trying to detect windows opened before yabai launch [#2208](https://github.com/koekeishiya/yabai/issues/2208)
- Fixed issue that could cause a crash when terminating an application in rare cases where there is a large backlog of events [#2210](https://github.com/koekeishiya/yabai/issues/2210)

## [7.0.4] - 2024-03-30
### Changed
Expand Down
8 changes: 6 additions & 2 deletions src/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ static EVENT_HANDLER(APPLICATION_TERMINATED)

for (int i = 0; i < window_count; ++i) {
struct window *window = window_list[i];
if (!__sync_bool_compare_and_swap(&window->id_ptr, &window->id, NULL)) continue;

if (!__sync_bool_compare_and_swap(&window->id_ptr, &window->id, NULL)) {
window->application = NULL;
continue;
}

struct view *view = window_manager_find_managed_window(&g_window_manager, window);
if (view) {
Expand Down Expand Up @@ -530,7 +534,7 @@ static EVENT_HANDLER(WINDOW_DESTROYED)
return;
}

debug("%s: %s %d\n", __FUNCTION__, window->application->name, window->id);
debug("%s: %s %d\n", __FUNCTION__, window->application ? window->application->name : "<unknown>", window->id);

struct view *view = window_manager_find_managed_window(&g_window_manager, window);
if (view) {
Expand Down
2 changes: 1 addition & 1 deletion src/event_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void event_signal_push(enum signal_type type, void *context)
snprintf(es->arg_name[0], arg_size, "%s", "YABAI_WINDOW_ID");
snprintf(es->arg_value[0], arg_size, "%d", window->id);

es->app = ts_string_copy(window->application->name);
es->app = window->application ? ts_string_copy(window->application->name) : "<unknown>";
es->active = g_window_manager.focused_window_id == window->id;
} break;
case SIGNAL_WINDOW_MOVED:
Expand Down

0 comments on commit 488671e

Please sign in to comment.