• Cherry Zhang's avatar
    cmd/compile: fix possible spill of invalid pointer with DUFFZERO on AMD64 · 111d590f
    Cherry Zhang authored
    SSA compiler on AMD64 may spill Duff-adjusted address as scalar. If
    the object is on stack and the stack moves, the spilled address become
    invalid.
    
    Making the spill pointer-typed does not work. The Duff-adjusted address
    points to the memory before the area to be zeroed and may be invalid.
    This may cause stack scanning code panic.
    
    Fix it by doing Duff-adjustment in genValue, so the intermediate value
    is not seen by the reg allocator, and will not be spilled.
    
    Add a test to cover both cases. As it depends on allocation, it may
    be not always triggered.
    
    Fixes #16515.
    
    Change-Id: Ia81d60204782de7405b7046165ad063384ede0db
    Reviewed-on: https://go-review.googlesource.com/25309
    Run-TryBot: Cherry Zhang <cherryyz@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarDavid Chase <drchase@google.com>
    111d590f
Name
Last commit
Last update
..
cgen.go Loading commit data...
galign.go Loading commit data...
ggen.go Loading commit data...
gsubr.go Loading commit data...
peep.go Loading commit data...
prog.go Loading commit data...
reg.go Loading commit data...
ssa.go Loading commit data...