Unsafe lifetime transmute in AppContext::make_surface #672
Labels
No labels
Context: Bug
Context: Enhancements
Platform: Android
Platform: Linux
Platform: Web
Platform: Windows
Platform: iOS
Platform: macOS
Target: CI
Target: CLI
Target: Dependency
Target: Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SakulFlee/Orbital#672
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: 🟡 Medium
File:
Crates/orbital_app/src/context.rs:109Bug:
The
make_surfacemethod uses an unsafetransmuteto extend aSurface<'_>toSurface<'static>:While the struct layout currently works with the Instance field before the Surface field, this is technically unsound. If the struct fields are ever reordered, the
Surfacecould dangle.Impact: Potential use-after-free if code is refactored.
Possible fix: Store the
Instancein anArcshared with theSurface, or usecreate_surfacewith theInstancedirectly if the API allows tying lifetimes properly.@SakulFlee