Upgrade rune from 0.13 to 0.14#159
Open
vponomaryov wants to merge 2 commits intomainfrom
Open
Conversation
ThreadRng contains Rc<UnsafeCell<...>> pointing to thread-local storage, making it !Send. While the field was never read or written by any code, its construction (rand::rng()) and destruction involved Rc refcount operations on thread-local data. When tokio migrated tasks between worker threads, the Rc drop could race with Rc operations on the originating thread, causing data corruption and segfaults. This was the root cause of intermittent crashes observed after switching to rune 0.14, where Context became VM-owned (created and dropped per call) rather than borrowed via AnyObj::from_ref as in rune 0.13.
0.13 to 0.14
Adapt to rune 0.14 API changes: - AnyObj::from_ref/from_mut became pub(crate), so Context is now passed to the VM as an owned shallow clone via Value::new(context) instead of a borrowed reference. - Update Value/VmResult/VmError APIs to match 0.14 signatures (Value::Result → downcast, Shared removal, VmResult → Result, etc). - Retain unsafe impl Send/Sync for Context. This is sound because the only !Send field is `data: Value` (non-atomic Cell<usize> refcount), and within latte's architecture each Context instance is confined to sequential polling within a single tokio task — no concurrent access to the same Cell can occur. The previously-unsound ThreadRng field was removed in the prior commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adapt to rune
0.14API changes:AnyObj::from_ref/from_mutbecamepub(crate), soContextcan no longer be passed to the VM as a borrowed reference. Instead, each VM call receives an owned shallow clone viaValue::new(context).Update
Value/VmResult/VmErrorAPIs to match0.14signatures(VmResult<T> → Result<T, RuntimeError>, Shared removal, etc).Remove unused
ThreadRngfield from Context which was causing data corruption on high load.Closes: #QATOOLS-10