Commit ebcdda47 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: fix crash in importer when running in debug mode

Verified by manually enabling debug mode and running make.bash.

Fixes #20684.

Change-Id: I041f2ca6ef1d4198815724d98f61511072d63581
Reviewed-on: https://go-review.googlesource.com/45971
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 6e549d2d
......@@ -564,7 +564,12 @@ func (p *exporter) pos(n *Node) {
func (p *exporter) path(s string) {
if i, ok := p.pathIndex[s]; ok {
p.index('p', i) // i >= 0
// Note: Using p.index(i) here requires the use of p.tag(-len(c)) below
// to get matching debug markers ('t'). But in trace mode p.tag
// assumes that the tag argument is a valid tag that can be looked
// up in the tagString list, rather then some arbitrary slice length.
// Use p.int instead.
p.int(i) // i >= 0
return
}
p.pathIndex[s] = len(p.pathIndex)
......
......@@ -420,12 +420,9 @@ func (p *importer) pos() src.XPos {
}
func (p *importer) path() string {
if p.debugFormat {
p.marker('p')
}
// if the path was seen before, i is its index (>= 0)
// (the empty string is at index 0)
i := p.rawInt64()
i := p.int()
if i >= 0 {
return p.pathList[i]
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment