]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.16] cmd/compile: fix panic in DWARF-gen handling obfuscated code
authorThan McIntosh <thanm@google.com>
Fri, 19 Feb 2021 15:09:15 +0000 (10:09 -0500)
committerDmitri Shuralyov <dmitshur@golang.org>
Mon, 1 Mar 2021 20:13:56 +0000 (20:13 +0000)
commit18e5d75ffb3c8d2be8c92f801aded70321e0b84b
treebd911dfa9ed76fd9ea057e6c8ed2bc96f9f38cd1
parentddeae6b248e5130fe634047c3ca5964f5fa4e3dd
[release-branch.go1.16] 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 #44433.

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>
(cherry picked from commit e78e04ce39b9df316edda08f43f253f5e9ac509e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/294789
src/cmd/compile/internal/gc/dwinl.go
test/fixedbugs/issue44378.go [new file with mode: 0644]