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

[client] overlay/msg: fix race condition in render #1162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spencercw
Copy link
Contributor

If an overlay is closed with overlayMsg_close, the message can be freed while it is still being used by msg_render, resulting in a segfault. Lock the message list for the duration of msg_render to fix this.

A semi-reliable way to reproduce this is to put a 20ms sleep after the call to ll_peek_head in msg_render. Use remote desktop to stop the Looking Glass host service, then start the client. The 'host not running' message should appear. Now start the host service. The client will now probably crash somewhere inside msg_render because the message it is rendering has been freed by overlayMsg_close.

Not sure this is the cleanest approach, but I've taken after the precedence of ll_forEachNL by adding some more nl methods. Perhaps it would be better to add a new lock in msg.c.

If an overlay is closed with overlayMsg_close, the message can be freed
while it is still being used by msg_render, resulting in a segfault. Lock
the message list for the duration of msg_render to fix this.
@gnif
Copy link
Owner

gnif commented Feb 11, 2025

Honestly I am not surprised there is an issue here, the code that handles the messages has not been looked at in quite some time. Thanks for this!

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