aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/dwarfgen
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2021-02-19 10:09:15 -0500
committerThan McIntosh <thanm@google.com>2021-02-21 02:25:26 +0000
commite78e04ce39b9df316edda08f43f253f5e9ac509e (patch)
tree8987ce4a11f20051c05db9f5cee3e7ff33170b13 /src/cmd/compile/internal/dwarfgen
parent03d36d8198428a6970ba01f5de41c264acbff8fc (diff)
downloadgo-e78e04ce39b9df316edda08f43f253f5e9ac509e.tar.gz
go-e78e04ce39b9df316edda08f43f253f5e9ac509e.zip
cmd/compile: fix panic in DWARF-gen handling obfuscated code
DWARF generation uses variable source positions (file/line/col) as a way to uniquely identify locals and parameters, as part of the process of matching up post-optimization variables with the corresponding pre-optimization versions (since the DWARF needs to be in terms of the original source constructs). This strategy can run into problems when compiling obfuscated or machine-generated code, where you can in some circumstances wind up with two local variables that appear to have the same name, file, line, and column. This patch changes DWARF generation to skip over such duplicates as opposed to issuing a fatal error (if an obfuscation tool is in use, it is unlikely that a human being will be able to make much sense of DWARF info in any case). Fixes #44378. Change-Id: I198022d184701aa9ec3dce42c005d29b72d2e321 Reviewed-on: https://go-review.googlesource.com/c/go/+/294289 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/dwarfgen')
-rw-r--r--src/cmd/compile/internal/dwarfgen/dwinl.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/dwarfgen/dwinl.go b/src/cmd/compile/internal/dwarfgen/dwinl.go
index d5687cb1d7..8adb36fc88 100644
--- a/src/cmd/compile/internal/dwarfgen/dwinl.go
+++ b/src/cmd/compile/internal/dwarfgen/dwinl.go
@@ -247,7 +247,8 @@ func makePreinlineDclMap(fnsym *obj.LSym) map[varPos]int {
DeclCol: pos.Col(),
}
if _, found := m[vp]; found {
- base.Fatalf("child dcl collision on symbol %s within %v\n", n.Sym().Name, fnsym.Name)
+ // We can see collisions (variables with the same name/file/line/col) in obfuscated or machine-generated code -- see issue 44378 for an example. Skip duplicates in such cases, since it is unlikely that a human will be debugging such code.
+ continue
}
m[vp] = i
}