Skip to content

Commit 6582ee9

Browse files
committed
test: new test for issue 30908
New test case designed to mimic the code in issue 30908, which features duplicate but non-indentical DWARF abstract subprogram DIEs. Updates #30908. Change-Id: Iacb4b53e6a988e46c801cdac236cef883c553f8f Reviewed-on: https://go-review.googlesource.com/c/go/+/168957 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
1 parent fbd74a8 commit 6582ee9

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

test/fixedbugs/issue30908.dir/a.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package a
6+
7+
import (
8+
"errors"
9+
"strings"
10+
)
11+
12+
var G interface{}
13+
14+
func Unmarshal(data []byte, o interface{}) error {
15+
G = o
16+
v, ok := o.(*map[string]interface{})
17+
if !ok {
18+
return errors.New("eek")
19+
}
20+
vals := make(map[string]interface{})
21+
s := string(data)
22+
items := strings.Split(s, " ")
23+
var err error
24+
for _, item := range items {
25+
vals[item] = s
26+
if item == "error" {
27+
err = errors.New("ouch")
28+
}
29+
}
30+
*v = vals
31+
return err
32+
}

test/fixedbugs/issue30908.dir/b.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package b
6+
7+
import (
8+
"io/ioutil"
9+
10+
"./a"
11+
)
12+
13+
var G int
14+
15+
// An inlinable function. To trigger the bug in question this needs
16+
// to be inlined here within the package and also inlined into some
17+
// other package that imports it.
18+
func ReadValues(data []byte) (vals map[string]interface{}, err error) {
19+
err = a.Unmarshal(data, &vals)
20+
if len(vals) == 0 {
21+
vals = map[string]interface{}{}
22+
}
23+
return
24+
}
25+
26+
// A local call to the function above, which triggers the "move to heap"
27+
// of the output param.
28+
func CallReadValues(filename string) (map[string]interface{}, error) {
29+
defer func() { G++ }()
30+
data, err := ioutil.ReadFile(filename)
31+
if err != nil {
32+
return map[string]interface{}{}, err
33+
}
34+
return ReadValues(data)
35+
}

test/fixedbugs/issue30908.dir/m.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"os"
9+
10+
"./b"
11+
)
12+
13+
func main() {
14+
seed := "some things are better"
15+
bsl := []byte(seed)
16+
b.CallReadValues("/dev/null")
17+
vals, err := b.ReadValues(bsl)
18+
if vals["better"] != seed || err != nil {
19+
os.Exit(1)
20+
}
21+
}

test/fixedbugs/issue30908.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rundir -P -l=4 -ldflags -strictdups=2
2+
3+
// Copyright 2019 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// +build !nacl,!js
8+
9+
package ignored

0 commit comments

Comments
 (0)