-
Notifications
You must be signed in to change notification settings - Fork 951
Fix panic when size 0 passed to malloc #3303
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e646a0d
to
46701eb
Compare
dgryski
approved these changes
Nov 21, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
lann
added a commit
to lann/tinygo
that referenced
this pull request
Jan 24, 2023
PR tinygo-org#3303 addressed panics when malloc'ing with size 0 by returning nil. While this is permitted by the C standard, some wasm environments expect the behavior to match that of glibc/dlmalloc, which is to always return a unique pointer.
Mossaka
added a commit
to Mossaka/wit-bindgen
that referenced
this pull request
Jan 31, 2023
The issue with "fragment is larger than or outside of variable" is a known issue and has been resolved in tinygo v0.26. However, tinygo v0.26 introduces a regression for wasm/wasi target where the compiler panics when size 0 passed to malloc. See tinygo-org/tinygo#3303 for details Signed-off-by: Jiaxiao Zhou <[email protected]>
Merged
alexcrichton
pushed a commit
to bytecodealliance/wit-bindgen
that referenced
this pull request
Feb 16, 2023
* created wit-bindgen-gen-guest-go crate and added to the clap CLI Signed-off-by: Jiaxiao Zhou <[email protected]> * rewrote import and export using a more generic conversion method Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: records working Signed-off-by: Jiaxiao Zhou <[email protected]> * simply code Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: tuple works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: list works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: string works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: option works Signed-off-by: Jiaxiao Zhou <[email protected]> * implemented result type Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: result works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: result option work Signed-off-by: Jiaxiao Zhou <[email protected]> * added codegen for go bindgen. Further work needs to pass all the tests Signed-off-by: Jiaxiao Zhou <[email protected]> * get more tests passed, including conventions Signed-off-by: Jiaxiao Zhou <[email protected]> * now flags and alias are working Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: implemented multi-return Signed-off-by: Jiaxiao Zhou <[email protected]> cargo clippy Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: implemented union, enum and variantss Signed-off-by: Jiaxiao Zhou <[email protected]> * rewrite lower's Result for imports * avoid Go keywords conflict with wit's variable names Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: all codegen tests passed. The issue with "fragment is larger than or outside of variable" is a known issue and has been resolved in tinygo v0.26. However, tinygo v0.26 introduces a regression for wasm/wasi target where the compiler panics when size 0 passed to malloc. See tinygo-org/tinygo#3303 for details Signed-off-by: Jiaxiao Zhou <[email protected]> * refactor: add gen-guest-c dependency to gen-guest-go. Signed-off-by: Jiaxiao Zhou <[email protected]> * cargo lock file Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: passed new tests associated cross-interface feature Signed-off-by: Jiaxiao Zhou <[email protected]> * formatted code Signed-off-by: Jiaxiao Zhou <[email protected]> * gh action: installed tinygo Signed-off-by: Jiaxiao Zhou <[email protected]> * install go 1.19 Signed-off-by: Jiaxiao Zhou <[email protected]> * generate C files together with Go files Signed-off-by: Jiaxiao Zhou <[email protected]> * added option-result test Signed-off-by: Jiaxiao Zhou <[email protected]> * fix a typo in wit-bindgen-cli doc Signed-off-by: Jiaxiao Zhou <[email protected]> * updated README to include gen-guest-go Signed-off-by: Jiaxiao Zhou <[email protected]> * removed option-result.wit Signed-off-by: Jiaxiao Zhou <[email protected]> * fix the broken CLI Signed-off-by: Jiaxiao Zhou <[email protected]> * added go to runtime test Signed-off-by: Jiaxiao Zhou <[email protected]> * free C parameters and variables Signed-off-by: Jiaxiao Zhou <[email protected]> * removed memory free for return variables in export and invoke arguments in import Signed-off-by: Jiaxiao Zhou <[email protected]> * implemented lists Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed a small bug around lowering nested option types Signed-off-by: Jiaxiao Zhou <[email protected]> * improve readability of code Signed-off-by: Jiaxiao Zhou <[email protected]> * changed the variant's package name to the world's name. Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: re-implement results Signed-off-by: Jiaxiao Zhou <[email protected]> * Fixed a small reference issue for lowering result * re-implement variants and unions Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed a few small bugs around variants and union types. Added variant runtime tests Signed-off-by: Jiaxiao Zhou <[email protected]> * turn off gc-leaking in tinygo 0.26 Signed-off-by: Jiaxiao Zhou <[email protected]> * simplify code and add multi-return to lowering * Added runtime tests for list, number and variant * Added flavorful runtime test * Added tests for many_aguments, records and smoke * Added strings and unions runtime tests * removed http from runtime test Signed-off-by: Jiaxiao Zhou <[email protected]> * added go bindgen build step to ci * updated tinygo to 0.27. All tests should pass now Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed go version to 1.20 instead of 1.2 Signed-off-by: Jiaxiao Zhou <[email protected]> * disable string test because unicode hasn't been handled properly Signed-off-by: Jiaxiao Zhou <[email protected]> * deleted wasm abi flag * merged main Signed-off-by: Jiaxiao Zhou <[email protected]> * Move go's files to it's own subfolder * move C gen files to its own folder Signed-off-by: Jiaxiao Zhou <[email protected]> * update go from 1.19 to 1.20 Signed-off-by: Jiaxiao Zhou <[email protected]> * changed tinygo crate version to 0.1.0 Signed-off-by: Jiaxiao Zhou <[email protected]> * diable variants test for go Signed-off-by: Jiaxiao Zhou <[email protected]> * Fixed a missing argument to encode * Fix referring to foreign imported paths in go Signed-off-by: Jiaxiao Zhou <[email protected]> * disable lift-foreign tests for now Signed-off-by: Jiaxiao Zhou <[email protected]> * run rustfmt Signed-off-by: Jiaxiao Zhou <[email protected]> --------- Signed-off-by: Jiaxiao Zhou <[email protected]>
rvolosatovs
pushed a commit
to bytecodealliance/wrpc
that referenced
this pull request
May 23, 2024
* created wit-bindgen-gen-guest-go crate and added to the clap CLI Signed-off-by: Jiaxiao Zhou <[email protected]> * rewrote import and export using a more generic conversion method Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: records working Signed-off-by: Jiaxiao Zhou <[email protected]> * simply code Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: tuple works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: list works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: string works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: option works Signed-off-by: Jiaxiao Zhou <[email protected]> * implemented result type Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: result works Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: result option work Signed-off-by: Jiaxiao Zhou <[email protected]> * added codegen for go bindgen. Further work needs to pass all the tests Signed-off-by: Jiaxiao Zhou <[email protected]> * get more tests passed, including conventions Signed-off-by: Jiaxiao Zhou <[email protected]> * now flags and alias are working Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: implemented multi-return Signed-off-by: Jiaxiao Zhou <[email protected]> cargo clippy Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: implemented union, enum and variantss Signed-off-by: Jiaxiao Zhou <[email protected]> * rewrite lower's Result for imports * avoid Go keywords conflict with wit's variable names Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: all codegen tests passed. The issue with "fragment is larger than or outside of variable" is a known issue and has been resolved in tinygo v0.26. However, tinygo v0.26 introduces a regression for wasm/wasi target where the compiler panics when size 0 passed to malloc. See tinygo-org/tinygo#3303 for details Signed-off-by: Jiaxiao Zhou <[email protected]> * refactor: add gen-guest-c dependency to gen-guest-go. Signed-off-by: Jiaxiao Zhou <[email protected]> * cargo lock file Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: passed new tests associated cross-interface feature Signed-off-by: Jiaxiao Zhou <[email protected]> * formatted code Signed-off-by: Jiaxiao Zhou <[email protected]> * gh action: installed tinygo Signed-off-by: Jiaxiao Zhou <[email protected]> * install go 1.19 Signed-off-by: Jiaxiao Zhou <[email protected]> * generate C files together with Go files Signed-off-by: Jiaxiao Zhou <[email protected]> * added option-result test Signed-off-by: Jiaxiao Zhou <[email protected]> * fix a typo in wit-bindgen-cli doc Signed-off-by: Jiaxiao Zhou <[email protected]> * updated README to include gen-guest-go Signed-off-by: Jiaxiao Zhou <[email protected]> * removed option-result.wit Signed-off-by: Jiaxiao Zhou <[email protected]> * fix the broken CLI Signed-off-by: Jiaxiao Zhou <[email protected]> * added go to runtime test Signed-off-by: Jiaxiao Zhou <[email protected]> * free C parameters and variables Signed-off-by: Jiaxiao Zhou <[email protected]> * removed memory free for return variables in export and invoke arguments in import Signed-off-by: Jiaxiao Zhou <[email protected]> * implemented lists Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed a small bug around lowering nested option types Signed-off-by: Jiaxiao Zhou <[email protected]> * improve readability of code Signed-off-by: Jiaxiao Zhou <[email protected]> * changed the variant's package name to the world's name. Signed-off-by: Jiaxiao Zhou <[email protected]> * milestone: re-implement results Signed-off-by: Jiaxiao Zhou <[email protected]> * Fixed a small reference issue for lowering result * re-implement variants and unions Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed a few small bugs around variants and union types. Added variant runtime tests Signed-off-by: Jiaxiao Zhou <[email protected]> * turn off gc-leaking in tinygo 0.26 Signed-off-by: Jiaxiao Zhou <[email protected]> * simplify code and add multi-return to lowering * Added runtime tests for list, number and variant * Added flavorful runtime test * Added tests for many_aguments, records and smoke * Added strings and unions runtime tests * removed http from runtime test Signed-off-by: Jiaxiao Zhou <[email protected]> * added go bindgen build step to ci * updated tinygo to 0.27. All tests should pass now Signed-off-by: Jiaxiao Zhou <[email protected]> * fixed go version to 1.20 instead of 1.2 Signed-off-by: Jiaxiao Zhou <[email protected]> * disable string test because unicode hasn't been handled properly Signed-off-by: Jiaxiao Zhou <[email protected]> * deleted wasm abi flag * merged main Signed-off-by: Jiaxiao Zhou <[email protected]> * Move go's files to it's own subfolder * move C gen files to its own folder Signed-off-by: Jiaxiao Zhou <[email protected]> * update go from 1.19 to 1.20 Signed-off-by: Jiaxiao Zhou <[email protected]> * changed tinygo crate version to 0.1.0 Signed-off-by: Jiaxiao Zhou <[email protected]> * diable variants test for go Signed-off-by: Jiaxiao Zhou <[email protected]> * Fixed a missing argument to encode * Fix referring to foreign imported paths in go Signed-off-by: Jiaxiao Zhou <[email protected]> * disable lift-foreign tests for now Signed-off-by: Jiaxiao Zhou <[email protected]> * run rustfmt Signed-off-by: Jiaxiao Zhou <[email protected]> --------- Signed-off-by: Jiaxiao Zhou <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently it will panic (I think Go may translate
&buf[0]
without a length check)https://linux.die.net/man/3/realloc
malloc
/calloc
can returnNULL
for empty sizerealloc
with empty is equivalent tofree