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

Calling Context::load_texture with a write lock held to the InputState causes a deadlock #2064

Closed
Ununoctium117 opened this issue Sep 20, 2022 · 0 comments · Fixed by #2625
Closed
Labels
bug Something is broken

Comments

@Ununoctium117
Copy link

Describe the bug

Context::load_texture acquires a read lock to the context's InputState, which is unexpected. I discovered this by accidentally holding a handle from Context::input_mut for longer than necessary, and calling load_texture with it held. At time of writing, the lock is acquired here: https://github.com/emilk/egui/blob/master/crates/egui/src/context.rs#L755

To Reproduce
Steps to reproduce the behavior:

  1. Call Context::input_mut in your UI code to query user inputs.
  2. Later (perhaps in response to user action consumed with InputState::consume_key), call Context::load_texture, before the MappedRwLockWriteGuard from input_mut is dropped.

I can write a minimal working example later if needed, but hopefully this is clear enough.

Expected behavior
Texture loading code would not interact with InputState.

Screenshots
N/A

Desktop (please complete the following information):
This isn't OS specific.

Additional context
It seems strange that loading a texture would have anything to do with the user input, but this could reasonably be solved by documenting this behavior on Context::load_texture. It's easy enough to work around (just drop the lock guard earlier), but it's tricky to realize what's happening without debugging egui code.

@Ununoctium117 Ununoctium117 added the bug Something is broken label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant