From: Joe Tsai Date: Mon, 23 Jun 2025 23:36:25 +0000 (-0700) Subject: cmd/dist: test encoding/json/... with GOEXPERIMENT=jsonv2 X-Git-Tag: go1.25rc2~2^2~39 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f866958246556ec609b81d31376a39efe9d51a51;p=gostls13.git cmd/dist: test encoding/json/... with GOEXPERIMENT=jsonv2 This also updates wasip1_wasm to use a 8MiB stack, which is the same stack size as what is used by go_js_wasm_exec. The increase of stack size is necessary because the jsonv2 tests exercise that the jsonv2 and jsontext packages support a hard limit of a maximum JSON nesting depth of 10000. However, even with a depth limit of 10000, this still exceeds the previously specified maximum stack size of 1 MiB. For use of JSON with untrusted inputs in WASM, we really need to support #56733 as there is no right answer for the default max depth limit to use since the max wasm stack size is determined on a per-system basis. Updates #71845 Change-Id: I3b32c58cc9f594a5c59bb3e4b20f5e86d85d8209 Reviewed-on: https://go-review.googlesource.com/c/go/+/683575 Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Reviewed-by: Johan Brandhorst-Satzkorn Reviewed-by: Damien Neil LUCI-TryBot-Result: Go LUCI --- diff --git a/lib/wasm/go_wasip1_wasm_exec b/lib/wasm/go_wasip1_wasm_exec index 3b2d12ec45..2de1758793 100755 --- a/lib/wasm/go_wasip1_wasm_exec +++ b/lib/wasm/go_wasip1_wasm_exec @@ -14,7 +14,7 @@ case "$GOWASIRUNTIME" in exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR:-/tmp}"/wazero ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}" ;; "wasmtime" | "") - exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" -W max-wasm-stack=1048576 ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}" + exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" -W max-wasm-stack=8388608 ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}" ;; *) echo "Unknown Go WASI runtime specified: $GOWASIRUNTIME" diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index c2eaeb1248..aa09d1eba3 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -743,6 +743,15 @@ func (t *tester) registerTests() { } } + // Test GOEXPERIMENT=jsonv2. + if !strings.Contains(goexperiment, "jsonv2") { + t.registerTest("GOEXPERIMENT=jsonv2 go test encoding/json/...", &goTest{ + variant: "jsonv2", + env: []string{"GOEXPERIMENT=jsonv2"}, + pkg: "encoding/json/...", + }) + } + // Test ios/amd64 for the iOS simulator. if goos == "darwin" && goarch == "amd64" && t.cgoEnabled { t.registerTest("GOOS=ios on darwin/amd64",