@FSMaxB Found a pattern for my current problem that compiles and works.
Creation:
let vmctx = RwLock::new(unsafe { Arc::from_raw(vmctx_mmap.as_mut_ptr().cast::<VmCtx>()) });
Example use:
Arc::get_mut(&mut self.vmctx.write().unwrap()).unwrap().regs[reg as usize] = value;
This whole topic gained my interest because I incorrectly first used Box here. In this case Arc is the solution because it does “just drop” instead of “drop + free” (Box).
@FSMaxB This actually did not work
$ cargo b
warning: /home/jarkko/work/github.com/jarkkojs/polkavm/Cargo.toml: unused manifest key: workspace.lints.rust.unexpected_cfgs.check-cfg
Compiling polkavm v0.15.0 (/home/jarkko/work/github.com/jarkkojs/polkavm/crates/polkavm)
error[E0308]: mismatched types
--> crates/polkavm/src/sandbox/linux.rs:1596:13
|
1596 | vmctx,
| ^^^^^ expected `RwLock<VmCtx>`, found `RwLock<&mut VmCtx>`
|
= note: expected struct `RwLock<VmCtx>`
found struct `RwLock<&mut VmCtx>`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `polkavm` (lib) due to previous error
I’m sure I can solve it just putting a note in order to not spread FUD ;-)
dtrace.conf(24) is going virtual! We're one month away from the un-conference and are opening the virtual ticket booth for this free event, with optional add-ons for event t-shirts and an on-site social in Emeryville after the event. Bring your topics and prepare to discuss! https://dtraceconf24.eventbrite.com