Skip to content
Snippets Groups Projects
  • Cherry Zhang's avatar
    b1f9f479
    [dev.link] cmd/link: fix payload pointer liveness · b1f9f479
    Cherry Zhang authored
    Currently, the symbol updater uses a pointer pointing to the
    loader's payloads array. If the payloads slice grows (and moves),
    the pointer may become stale and no longer point to the symbol's
    actual payload. Specifically, consider
    
    	sb, sym := l.MakeSymbolUpdater(...)
    	// add a bunch of external symbols, which grows payload slice
    	sb.SetType(t)
    	l.SymType(sym) // may not return t
    
    sb.SetType on line 3 may not have the desired effect, as
    sb.extSymPayload may no longer point to the right payload. As a
    result, the type we get on line 4 may be not the one we set.
    
    Fix this by making the payload's address permanent. Once it is
    allocated it will never move.
    
    Change-Id: Iab190ea5aceb5c37f91d09ad4ffd458e881b03f4
    Reviewed-on: https://go-review.googlesource.com/c/go/+/217063
    
    
    Run-TryBot: Cherry Zhang <cherryyz@google.com>
    Reviewed-by: default avatarJeremy Faller <jeremy@golang.org>
    b1f9f479
    History
    [dev.link] cmd/link: fix payload pointer liveness
    Cherry Zhang authored
    Currently, the symbol updater uses a pointer pointing to the
    loader's payloads array. If the payloads slice grows (and moves),
    the pointer may become stale and no longer point to the symbol's
    actual payload. Specifically, consider
    
    	sb, sym := l.MakeSymbolUpdater(...)
    	// add a bunch of external symbols, which grows payload slice
    	sb.SetType(t)
    	l.SymType(sym) // may not return t
    
    sb.SetType on line 3 may not have the desired effect, as
    sb.extSymPayload may no longer point to the right payload. As a
    result, the type we get on line 4 may be not the one we set.
    
    Fix this by making the payload's address permanent. Once it is
    allocated it will never move.
    
    Change-Id: Iab190ea5aceb5c37f91d09ad4ffd458e881b03f4
    Reviewed-on: https://go-review.googlesource.com/c/go/+/217063
    
    
    Run-TryBot: Cherry Zhang <cherryyz@google.com>
    Reviewed-by: default avatarJeremy Faller <jeremy@golang.org>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.