]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: don't crash when using trace with an invalid argument
authorRobert Griesemer <gri@golang.org>
Wed, 7 Jun 2023 01:46:29 +0000 (18:46 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 7 Jun 2023 02:51:54 +0000 (02:51 +0000)
This only affects tests, typically manual tests, but when using trace
we're debugging and we don't want to crash because of trace itself.

No test because a test would cause trace output. Manually verified.

Fixes #60649.

Change-Id: I97abdb94db05774801ec5da56171f4a1aff35615
Reviewed-on: https://go-review.googlesource.com/c/go/+/501415
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/types2/builtins.go
src/go/types/builtins.go

index a65054661e129edd152b2ae59aa4e8032f3d498e..a3e1981af6e6e6ea58bfd3105a27858bfba3b45d 100644 (file)
@@ -893,6 +893,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        check.dump("%v: %s", atPos(x1), x1)
                        x1 = &t // use incoming x only for first argument
                }
+               if x.mode == invalid {
+                       return
+               }
                // trace is only available in test mode - no need to record signature
 
        default:
index fcbb71249463cb30edda3513b55ec850727098ba..837a9b5e14d632e2a2c9aa48dd5fb7e6d464c289 100644 (file)
@@ -892,6 +892,9 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        check.dump("%v: %s", x1.Pos(), x1)
                        x1 = &t // use incoming x only for first argument
                }
+               if x.mode == invalid {
+                       return
+               }
                // trace is only available in test mode - no need to record signature
 
        default: