Repository navigation
Conversation
These functions modify the logical_device_list which is protected only by the loader_lock. These functions are passed to layers as callbacks with no restrictions on when to call them. Therefore, these functions must acquire the loader_lock. Since 5ee27b3 the lock is recursive, which means that acquiring it in these functions will not deadlock even if the callbacks are called while the loader is already holding the lock in the current thread. Fixes KhronosGroup#2052 by fully serializing device creation and destruction. Signed-off-by: Julian Orth <ju.orth@gmail.com>
|
User mahkoh not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
User mahkoh not on autobuild list. Waiting for curator authorization before starting CI build. |
|
|
There was a problem hiding this comment.
🟡 Changes recommended
The new cross-thread serialization behavior lacks regression coverage.
1 open finding
What changed in this PR
Serializes layer-driven device creation and destruction with the recursive global loader lock, preventing logical-device list races and dispatch-pointer reuse ordering issues.
Changes:
- Locks
loader_layer_create_device. - Locks
loader_layer_destroy_device.
| File | Description |
|---|---|
loader/loader.c |
Protects device lifecycle callbacks with loader_lock. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| struct loader_device *dev = NULL; | ||
| struct loader_instance *inst = NULL; | ||
|
|
||
| loader_platform_thread_lock_mutex(&loader_lock); |

These functions modify the logical_device_list which is protected only by the loader_lock. These functions are passed to layers as callbacks with no restrictions on when to call them. Therefore, these functions must acquire the loader_lock.
Since 5ee27b3 the lock is recursive, which means that acquiring it in these functions will not deadlock even if the callbacks are called while the loader is already holding the lock in the current thread.
Fixes #2052 by fully serializing device creation and destruction.