Dropping all references to a Global
export leads to a use-after-free in returned NativeFunc
s
#2873
Labels
bug
Something isn't working
Describe the bug
When all references to a
NativeFunc
's Global externs are dropped and it is returned from a function then the extern takes a garbage value in the module.Steps to reproduce
This can be reproduce with a fresh Rust project and the following code.
Expected behavior
The above code outputs
Actual behavior
The above code outputs
I feel like
NativeFunc
instances either shouldn't be able to outlive their instance's exports or should keep a reference to them internally.Additional context
My actual use case doesn't require any of the allocation / reference counting performed by
Global
, and it would be nice if I could simply provide a value for immutable global exports.The text was updated successfully, but these errors were encountered: