Skip to content

cmd/compile: sanity check in makePreinlineDclMap can fail #38698

@josharian

Description

@josharian
package p

func ff( /*line :10*/ x string) bool {
	{
		var _ /*line :10*/, x int
		_ = x
	}
	return x == ""
}

func h(a string) bool {
	return ff(a)
}
$ go tool compile -S bug.go
:17: internal compiler error: child dcl collision on symbol x within "".ff


goroutine 1 [running]:
runtime/debug.Stack(0x19892e0, 0xc0000ac008, 0x0)
	/Users/josh/go/tip/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0x1829099, 0x2b, 0xc0003c2f68, 0x2, 0x2)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/subr.go:193 +0x1aa
cmd/compile/internal/gc.makePreinlineDclMap(0xc0003b4580, 0xc0003c31b8)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/dwinl.go:225 +0x337
cmd/compile/internal/gc.assembleInlines(0xc0003b4580, 0xc0003dc4c0, 0x3, 0x4, 0x4, 0xc0000b2cc0, 0x3)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/dwinl.go:106 +0x52d
cmd/compile/internal/gc.debuginfo(0xc0003b4580, 0xc0003b4680, 0x18056c0, 0xc00039e3c0, 0x20, 0x30, 0x30, 0xc0003d31d0, 0xc00008ed60, 0x10)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/pgen.go:434 +0x9b3
cmd/internal/obj.(*Link).DwarfAbstractFunc(0xc0001701a0, 0x18056c0, 0xc00039e3c0, 0xc0003b4580, 0x0, 0x0)
	/Users/josh/go/tip/src/cmd/internal/obj/objfile.go:675 +0xb6
cmd/compile/internal/gc.genAbstractFunc(0xc0003b4580)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/dwinl.go:195 +0xb8
cmd/internal/obj.(*DwarfFixupTable).Finalize(0xc0000b1140, 0x0, 0x0, 0x0)
	/Users/josh/go/tip/src/cmd/internal/obj/objfile.go:926 +0x224
cmd/compile/internal/gc.Main(0x18357e0)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/main.go:769 +0x3b67
main.main()
	/Users/josh/go/tip/src/cmd/compile/main.go:52 +0xac

This code is obviously contrived/ridiculous, but the point remains--in the presence of line directives, we cannot safely assume that the contents of any given source positions are unique.

cc @thanm

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions