Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfaults on output destruction #3399

Merged
merged 1 commit into from
Jan 10, 2019

Conversation

RedSoxFan
Copy link
Member

Fixes #3065

This fixes two causes of segfaulting when an output is destroyed.

The first occurred when an output was never enabled. The issue was that
the destroy signal was never initialized so when it was emitted, sway
segfaulted. This was fixed by moving the initialization into
output_create since all outputs, regardless of whether they have ever
been enabled, will be destroyed at some point.

The second occurred when the cursor was on an output that was being
destroyed. The sway output would have already been removed, but if there
are other outputs, a cursor rebase would still occur. Since the
wlr_output still existed and the sway output was destroyed, the cursor
could be over nothing, resulting in a segfault when trying to get the
sway output, which was destroyed.

@emersion
Copy link
Member

TBH I'm not a fan of dynamically adding/removing listeners when enabling/disabling outputs.

@@ -87,6 +87,10 @@ static struct sway_node *node_at_coords(
struct sway_output *output = wlr_output->data;
double ox = lx, oy = ly;
wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy);
if (!output) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this check on line 87?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, moved

This fixes two causes of segfaulting when an output is destroyed.

The first occurred when an output was never enabled. The issue was that
the destroy signal was never initialized so when it was emitted, sway
segfaulted. This was fixed by moving the initialization into
`output_create` since all outputs, regardless of whether they have ever
been enabled, will be destroyed at some point.

The second occurred when the cursor was on an output that was being
destroyed. The sway output would have already been removed, but if there
are other outputs, a cursor rebase would still occur. Since the
wlr_output still existed and the sway output was destroyed, the cursor
could be over nothing, resulting in a segfault when trying to get the
sway output, which was destroyed.
@RedSoxFan RedSoxFan force-pushed the fix-output-destruction-segfaults branch from 89958f4 to 8fd3f32 Compare January 10, 2019 08:07
@RedSoxFan
Copy link
Member Author

TBH I'm not a fan of dynamically adding/removing listeners when enabling/disabling outputs.

Well this is one step towards not dynamically adding/removing them since it moves the destroy listener out of output_enable and into output_create

@emersion emersion merged commit 9abac85 into swaywm:master Jan 10, 2019
@emersion
Copy link
Member

Thanks!

@RedSoxFan RedSoxFan deleted the fix-output-destruction-segfaults branch January 10, 2019 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Segfault on exit when an output is disabled
2 participants