dingo-hunter icon indicating copy to clipboard operation
dingo-hunter copied to clipboard

Φ-node where initial value is nil causes segfault

Open nickng opened this issue 9 years ago • 2 comments

In a Φ-node where the initial value is a typed constant, e.g. nil:[]int, Φ register will be stored as a "Panic:..." string (because we get the name of the initial register as reg.Name()) but does not terminate the program. Later when the Φ register is used, it causes a segfault.

The Φ-node always come after the initial register's assignment so a workround is to special-case when a Φ-node with nil initial value is present (e.g. store as a dummy register rather than trying to resolve the name). The type can be used to generate a zero value for the initial register.

nickng avatar Oct 12 '16 13:10 nickng

MWE

package main

func main() {
        var x []int
        for i := 0; i < 3; i++ {
                x = append(x, i)
        }
}

nickng avatar Oct 18 '16 14:10 nickng

This can be resolved by visiting the block from multiple edges into the block and assume the symbolic value to non-nil value.

nickng avatar Apr 10 '17 15:04 nickng