• Russ Cox's avatar
    runtime: change tinyalloc, persistentalloc not to point past allocated data · 0e840887
    Russ Cox authored
    During all.bash I got a crash in the GOMAXPROCS=2 runtime test reporting
    that the write barrier in the assignment 'c.tiny = add(x, size)' had been
    given a pointer pointing into an unexpected span. The problem is that
    the tiny allocation was at the end of a span and c.tiny was now pointing
    to the end of the allocation and therefore to the end of the span aka
    the beginning of the next span.
    
    Rewrite tinyalloc not to do that.
    
    More generally, it's not okay to call add(p, size) unless you know that p
    points at > (not just >=) size bytes. Similarly, pretty much any call to
    roundup doesn't know how much space p points at, so those are all
    broken.
    
    Rewrite persistentalloc not to use add(p, totalsize) and not to use roundup.
    
    There is only one use of roundup left, in vprintf, which is dead code.
    I will remove that code and roundup itself in a followup CL.
    
    Change-Id: I211e307d1a656d29087b8fd40b2b71010722fb4a
    Reviewed-on: https://go-review.googlesource.com/2814Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
    0e840887
mgc0.go 12.2 KB