Open
Description
VM
has a lifetime 'a
. This lifetime is arbitrary – it is chosen by the caller with no restrictions. This means it can outlive the VM
, but other structs assume the VM
is life for 'a
. This is unsound.
Segfaulting example:
let mut vm = create_base_vm(DEFAULT_MAX_MEMORY);
let call_stack = vm.allocate_call_stack();
let main_method = vm
.resolve_class_method(
call_stack,
"rjvm/SimpleMain",
"main",
"([Ljava/lang/String;)V",
)
.expect("should find main method");
drop(vm);
println!("{main_method:?}");
Possible solutions:
- Remove lifetime from
VM
. All methods that produce lifetimed objects take their lifetime from the reference to theVM
. - Remove lifetime from
VM
. Keep VM in anArc
. Erase lifetimes internally. Don't hand out structs referencing VM memory directly, instead hand out a wrapper object that also contains a copy of theArc
(this can be transparent to the user).
Metadata
Metadata
Assignees
Labels
No labels