• Russ Cox's avatar
    runtime: fix signal stack bug · 820dc9ff
    Russ Cox authored
    In CL 4188061 I changed malg to allocate the requested
    number of bytes n, not n+StackGuard, so that the
    allocations would use rounder numbers.
    
    The allocation of the signal stack asks for 32k and
    then used g->stackguard as the base, but g->stackguard
    is StackGuard bytes above the base.  Previously, asking
    for 32k meant getting 32k+StackGuard bytes, so using
    g->stackguard as the base was safe.  Now, the actual base
    must be computed, so that the signal handler does not
    run StackGuard bytes past the top of the stack.
    
    Was causing flakiness mainly in programs that use the
    network, because they sometimes write to closed network
    connections, causing SIGPIPEs.  Was also causing problems
    in the doc/progs test.
    
    Also fix Makefile so that changes to stack.h trigger rebuild.
    
    R=bradfitzgo, r, r2
    CC=golang-dev
    https://golang.org/cl/4230044
    820dc9ff
thread.c 6.71 KB