checkptr/race pointer arithmetic result to invalid allocation

321 views
Skip to first unread message

Richiise Nugraha

unread,
Jul 8, 2022, 12:18:57 PM7/8/22
to golang-nuts
Hi, i was testing this code on Go playground and it works just fine, however if i run with `-race` it throws `pointer arithmetic result points to invalid allocation` although it has the same address. What really causes this?, like the address (untouched) still a valid allocation

ptr = 0xc000138008
p = 0xc000138008
base = 0xc000138000
originals = []unsafe.Pointer len: 0, cap: 0, nil


Thanks

Ian Lance Taylor

unread,
Jul 8, 2022, 1:49:17 PM7/8/22
to Richiise Nugraha, golang-nuts
Your code is breaking the unsafe.Pointer rules documented at
https://pkg.go.dev/unsafe#Pointer.

Ian
Reply all
Reply to author
Forward
0 new messages