This is a bit of a hard to reproduce bug. You will need to run some tests from https://github.com/lunatic-solutions/lunatic-rs in a loop to trigger it:
while true; do
cargo test --test registry
done
I believe the issue is in this unsafe code:
|
// Extend the lifetime of the lock, so it can be saved across host calls. |
|
// Safety: |
|
// The process state (containing the lock) can't outlive the `RwLock`, |
|
// which is global. This makes it safe to extend the lifetime. |
|
let registry_lock: RwLockWriteGuard<'static, HashMap<String, (u64, u64)>> = |
|
unsafe { transmute(registry_lock) }; |
One way to resolve this would be to move the "lookup and insert" operation to the process spawning function. In that case we would not require to hold onto a lock across host-guest-host calls.
This is a bit of a hard to reproduce bug. You will need to run some tests from https://github.com/lunatic-solutions/lunatic-rs in a loop to trigger it:
I believe the issue is in this
unsafecode:lunatic/crates/lunatic-registry-api/src/lib.rs
Lines 177 to 182 in 07454fb
One way to resolve this would be to move the "lookup and insert" operation to the process spawning function. In that case we would not require to hold onto a lock across host-guest-host calls.