From ab79327e0571fe08aa15c08e5f3f38e548f7b520 Mon Sep 17 00:00:00 2001 From: Tim King Date: Mon, 10 Oct 2022 13:45:43 -0700 Subject: [PATCH] cmd/ssadump: disable run mode with runtime package Changes `ssadump -run` to ensure that the package runtime is not imported (changed from must be imported). For several years, the runtime package has used unsafe constructs x/tools/go/ssa/interp cannot interpret. This must have been failing a similar amount of time. This is unfortunate, but is unlikely to be addressed soon. For golang/go#43163 Change-Id: I9e2aee640ff7b1123e591e6c49cac9967c5e8da8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/441817 Run-TryBot: Tim King gopls-CI: kokoro Reviewed-by: Alan Donovan TryBot-Result: Gopher Robot --- cmd/ssadump/main.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/ssadump/main.go b/cmd/ssadump/main.go index 138e7f69ff..cfb9122b24 100644 --- a/cmd/ssadump/main.go +++ b/cmd/ssadump/main.go @@ -157,12 +157,15 @@ func doMain() error { // Build SSA for all packages. prog.Build() - // The interpreter needs the runtime package. - // It is a limitation of go/packages that - // we cannot add "runtime" to its initial set, - // we can only check that it is present. - if prog.ImportedPackage("runtime") == nil { - return fmt.Errorf("-run: program does not depend on runtime") + // Earlier versions of the interpreter needed the runtime + // package; however, interp cannot handle unsafe constructs + // used during runtime's package initialization at the moment. + // The key construct blocking support is: + // *((*T)(unsafe.Pointer(p))) + // Unfortunately, this means only trivial programs can be + // interpreted by ssadump. + if prog.ImportedPackage("runtime") != nil { + return fmt.Errorf("-run: program depends on runtime package (interpreter can run only trivial programs)") } if runtime.GOARCH != build.Default.GOARCH {