elliottt opened PR #9356 from elliottt:trevor/null-allocation-adapter
to bytecodealliance:main
:
The preview1 adapter has an implementation of cabi_realloc that facilitates calling component imports that return dynamically allocated results, like lists and strings. However, when returning a zero-length value to a buffer that's been allocated with zero bytes available, a trap will occur. This is because the alignment check requires that there is space left over after alignment has been added to the base pointer, which in the case of an empty buffer, will not be possible.
This PR fixes the issue by relaxing the alignment check to require that the amount required to align the base does not exceed the length of the buffer, but may consume the entire allocation.
elliottt requested wasmtime-core-reviewers for a review on PR #9356.
elliottt requested fitzgen for a review on PR #9356.
elliottt requested alexcrichton for a review on PR #9356.
alexcrichton commented on PR #9356:
Would it be possible to add a test for this as well? Or is that out-of-scope in the WASI APIs we have bound?
alexcrichton submitted PR review.
elliottt updated PR #9356.
elliottt updated PR #9356.
elliottt commented on PR #9356:
Would it be possible to add a test for this as well? Or is that out-of-scope in the WASI APIs we have bound?
The test added fails when the change to the
align_to
function is reverted, triggering the original issue in the adapter.
elliottt merged PR #9356.
Last updated: Dec 23 2024 at 12:05 UTC