Skip to content

Conversation

@alexcrichton
Copy link
Member

This commit updates Wasmtime's core Val::to_raw function a safe function. This was previously marked as unsafe with documentation that the raw pointer could be invalid, but that's not a reason for the function itself to be unsafe. Usage of the returned value is still unsafe, but simply acquiring the value is not itself an unsafe operation.

This additionally marks a number of GC-related from_raw functions as safe. Wasmtime's GC is safe in the face of heap corruption, so it's memory safe to pass in any 32-bit value. Documentation still indicates that panics are possible, however.

This commit updates Wasmtime's core `Val::to_raw` function a safe
function. This was previously marked as `unsafe` with documentation that
the raw pointer could be invalid, but that's not a reason for the
function itself to be `unsafe`. Usage of the returned value is still
`unsafe`, but simply acquiring the value is not itself an unsafe
operation.

This additionally marks a number of GC-related `from_raw` functions as
safe. Wasmtime's GC is safe in the face of heap corruption, so it's
memory safe to pass in any 32-bit value. Documentation still indicates
that panics are possible, however.
@alexcrichton alexcrichton requested a review from a team as a code owner July 24, 2025 19:40
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team July 24, 2025 19:40
@fitzgen fitzgen added this pull request to the merge queue Jul 24, 2025
Merged via the queue into bytecodealliance:main with commit 686ea89 Jul 24, 2025
42 checks passed
@alexcrichton alexcrichton deleted the to-raw-is-safe branch July 24, 2025 20:45
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
This commit updates Wasmtime's core `Val::to_raw` function a safe
function. This was previously marked as `unsafe` with documentation that
the raw pointer could be invalid, but that's not a reason for the
function itself to be `unsafe`. Usage of the returned value is still
`unsafe`, but simply acquiring the value is not itself an unsafe
operation.

This additionally marks a number of GC-related `from_raw` functions as
safe. Wasmtime's GC is safe in the face of heap corruption, so it's
memory safe to pass in any 32-bit value. Documentation still indicates
that panics are possible, however.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants