]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix crash in importer when running in debug mode
authorRobert Griesemer <gri@golang.org>
Thu, 15 Jun 2017 22:05:03 +0000 (15:05 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 15 Jun 2017 22:27:53 +0000 (22:27 +0000)
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: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go

index 868bbe73b0ab022210621ec3433a52795f804109..3ac81367048c8ea5c96095d6f5da61bde898a1da 100644 (file)
@@ -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)
index 30ee31af55fd5f3cf3ebd26de3d41c1855d286f5..282f8766e2b3dd9c3600c57368c579a8476b7bb0 100644 (file)
@@ -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]
        }