Skip to content

invalid memory reference (signal: 11) when using the new atomic registry API #189

@bkolobara

Description

@bkolobara

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions