Ian Lance Taylor
unread,Jul 8, 2025, 6:50:10 PMJul 8Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gcc-patches, gofrontend-dev
This libgo patch avoids the libc memmove and memclr functions when the
type being moved or cleared may contain pointer values. This is
necessary to ensure that Go's concurrent garbage collector doesn't see
corrupt pointer values.
The libc memmove and memclr don't reliably operate on full memory
words. We already avoided them on PPC64, but the same problem can
occur even on x86, where some processors use "rep movsb" and "rep
stosb". Always use C code that stores full memory words.
While we're here, clean up the C code. We don't need special handling
if the memmove/memclr pointers are not pointer-aligned.
Unfortunately, this will likely be slower. Perhaps some day we can
have our own assembly code that operates a word at a time, or we can
use different operations when we know there are no pointers.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian