Comments (6)
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
- Changing the return type of api.Memory Size to uint64
- This is somewhat breaking change, though the impact should be really minimum because this is just a integer type conversion.
- Adds another for
SizeSafe() uint64
or whatever it is while putting deprecation comments on the api.Memory Size.- This won't be a breaking change
thoughts? @evacchi @ncruces @achille-roussel
from wazero.
what about checking in the Grow method for this limit? I mean, instead of allowing the buffer size to reach 2^32 (which overflows uint32 only by 1) check and limit the buffer size/cap to be (2^32) - 1 then it will bound to uint32 limits (and the Size will not have problems to calc/return the correct size). I would assume that the problem with this approach is that the latest page will lose 1 byte (65535 instead of 65536), right?
no that's not our option as that means wazero is not compliant with the Wasm spec.
from wazero.
@mathetake thanks for the response, I have a question regards the Also, I would like to add that wasmtime SizeSafe
, what it will return in a case where the buffer size overflows uint32
limits?memory size
function returns a u64
I would like to add a third option:
- what about checking in the
Grow
method for this limit? I mean, instead of allowing the buffer size to reach 2^32 (which overflows uint32 only by 1) check and limit the buffer size/cap to be(2^32) - 1
then it will bound to uint32 limits (and the Size will not have problems to calc/return the correct size). I would assume that the problem with this approach is that the latest page will lose 1 byte (65535 instead of 65536), right?
from wazero.
Since memory size can't be (2^32) - 1
, I'd return that and document the corner case?
I'd maybe call the other method Size64
, in preparation for 64 bit memories?
from wazero.
@mathetake @ncruces thanks for the clarifications, I took the freedom to create a draft PR that introduces the new method #1856
from wazero.
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 Size64
.
Tomorrow I will raise a PR to do so, which supersedes #1856. Thank you for your help anyway @EclesioMeloJunior
from wazero.
Related Issues (20)
- More non-trivial examples HOT 4
- wazero running on embedded systems HOT 3
- thread-safety considerations for `Table` HOT 14
- Maybe allocate bug ? HOT 1
- Read directory bug ? HOT 1
- Wasm GC HOT 3
- Dynamically load WASM files HOT 1
- ` fd_fdstat_set_flags` truncates file HOT 1
- [WASI] `fd_fdstat_set_flags` with `fdflags::append` resets fd offset HOT 1
- `fd_filestat_set_size` wraps instead of error on large file size
- Inaccurate clock resolution in WASI `clock_res_get` HOT 3
- Feature Request: Rust tokio async interoperability through pollOneOff HOT 20
- Issue with reloading compiled module HOT 3
- flaky test: ExampleCoreFeaturesThreads HOT 2
- flaky test: internal/engine/wazevo.TestE2E on amd64 HOT 2
- flaky test: wasi_snapshot_preview1/wasi_stdlib_unix_test Test_NonblockingFile
- flaky test: TestFileCache_{compiler, wazevo} HOT 12
- Complex Types using WIT Supported HOT 2
- flaky test: TestPoll_Windows/poll_should_wait_for_the_given_duration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wazero.