-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api.Memory.Size() overflows when the memory has the maximum 65536 pages #1852
Comments
MemoryLimitPages
causes unexpected behaviors MemoryLimitPages
MemoryLimitPages
Thank you @EclesioMeloJunior for reporting this, and I confirmed that this is actually a bug in our API. As you described, when the memory has the maximum of 65536 pages, the buffer length becomes 2^32, which is larger than the maximum of uint32 which is the return type of api.Memory Size. We could do either
thoughts? @evacchi @ncruces @achille-roussel |
@mathetake thanks for the response, I would like to add a third option:
|
no that's not our option as that means wazero is not compliant with the Wasm spec. |
Since memory size can't be |
@mathetake @ncruces thanks for the clarifications, I took the freedom to create a draft PR that introduces the new method #1856 |
So we are looking to release wazero 2.0 next month, and I think we can make the breaking change to this rather than having another confusing api like Tomorrow I will raise a PR to do so, which supersedes #1856. Thank you for your help anyway @EclesioMeloJunior |
reopening this as we've decided to not fix this in 2.0, which is explained in detail in #2106 |
Maybe we could document the issue, and add a method |
I think we should:
Then we can close this? I mean, given the above, I guess the biggest deficiency is not the |
regardless of having new API or not, defer to @evacchi for any decision from now! |
Describe the bug
Basically, when calling
memory.Grow
function passing a delta that grows the memory to theMemoryLimitPages
(65536) returns successfully but when we callmemory.Size()
the number of pages mismatches the expected.I think that occurs because uint32 cannot fit the new buffer len (since the current page is
65536
and the number of bytes per page is65536
and the multiplication of these values overflows uint32)To Reproduce
I've wrote a test that reproduces the error in this fork ChainSafe#4
Expected behavior
Since the limit is
MemoryLimitPages
we should be able get the correct page size when growing up to that sizeScreenshots
N/A
Environment (please complete the relevant information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: