Repository navigation
cmd/wazero: exit non-zero on an invalid -listen or -mount - #2537
Merged
ncruces merged 2 commits intoAug 29, 2026
Merged
Conversation
validateListens returned the zero-valued named return from both of its failure branches, so the caller's `rc != 0` check never fired. The `!stat.IsDir()` branch of validateMounts printed its message and fell through with no return at all, mounting the file as a DirFS. In both cases `wazero run` printed the error, ran the module anyway and exited 0. Signed-off-by: Iain <[email protected]>
ncruces
approved these changes
Aug 29, 2026
Contributor
|
Seems reasonable. Can you fix the test? |
Contributor
Author
|
Cheers @ncruces, pushed. Only the mount row was broken - passing a bare file path meant Windows split on the drive-letter colon, so it stat'd |
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
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.
cmd/wazero/wazero_test.godoesn't contain the wordlistenanywhere, and the oneinvalid mountrow inTestRun_Errorshas// not foundsat next to it. Which is proably why nobody's noticed that three of the four cases below print an error and then run the module regardless.Each row is
wazero run <flags> cmd/wazero/testdata/wasi_arg.wasm, from the repo root:-mount=/nope/nopeinvalid mount: path "/nope/nope" error: stat ...-mount=cmd/wazero/testdata/fs/bear.txtinvalid mount: path "..." is not a directory-listen 8080invalid listen-listen localhost:abcinvalid listen port: strconv.Atoi: parsing "abc": invalid syntaxOnly the top one's right. The other three start the guest with no mount and no listener and still hand back 0, so a CI job wrapping
wazeropasses on a server that never listened.The listen side is worse than it looks:
validateListensnever assigns the namedrcit returns, so therc != 0branch in its caller has never fired.Three lines of fix against twelve of test, which is a daft ratio - they're three more rows in the existing
TestRun_Errorstable though, rather than a new harness.The mount change is the bit with any chance of biting someone. If you'd been pointing
-mountat a file and getting away with it, thats exit 1 now instead of aDirFSover a regular file. Nothing in the repo does that as far as I can see, I havent looked outside it.