Many thanks. This is quite informative.
On Wednesday, April 22, 2020 at 4:44:18 PM UTC-4, Ian Lance Taylor wrote:
>
> On Wed, Apr 22, 2020 at 7:08 AM T L >
> wrote:
> >
> > I understand that, by the case 6 in the unsafe package docs,
> > the second program should be safe with or without the ru
But it’s a data race regardless. Even if the runtime did interrupt the go
routine mid write and change the stack it would be forced to eventually correct
the value to have the write be valid - but if another routine is reading that
value, including the GC, there must be synchronization added. In
On Wed, Apr 22, 2020 at 7:08 AM T L wrote:
>
> I understand that, by the case 6 in the unsafe package docs,
> the second program should be safe with or without the runtime.KeepAlive call.
> I just wonder how Go runtime achieves this goal.
> I have an impression that pointer assignments in Go by gc
On Wed, Apr 22, 2020 at 4:33 AM T L wrote:
>
> On Tuesday, April 21, 2020 at 8:13:17 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Tue, Apr 21, 2020 at 8:17 AM T L wrote:
>> >
>> > And is the runtime.KeepAlive call in the following program essential to
>> > keep the correctness?
>> >
>> > package m
I understand that, by the case 6 in the unsafe package docs,
the second program should be safe with or without the runtime.KeepAlive
call.
I just wonder how Go runtime achieves this goal.
I have an impression that pointer assignments in Go by gc is atomically,
but is this also true for uintptr val
On Tuesday, April 21, 2020 at 8:13:17 PM UTC-4, Ian Lance Taylor wrote:
>
> On Tue, Apr 21, 2020 at 8:17 AM T L >
> wrote:
> >
> > And is the runtime.KeepAlive call in the following program essential to
> keep the correctness?
> >
> > package main
> >
> > import (
> > "fmt"
> >
On Tue, Apr 21, 2020 at 8:17 AM T L wrote:
>
> And is the runtime.KeepAlive call in the following program essential to keep
> the correctness?
>
> package main
>
> import (
> "fmt"
> "unsafe"
> "reflect"
> "runtime"
> )
>
> func main() {
> a := [6]byte{'G', 'o', 'o', 'g', 'l',
And is the runtime.KeepAlive call in the following program essential to
keep the correctness?
package main
import (
"fmt"
"unsafe"
"reflect"
"runtime"
)
func main() {
a := [6]byte{'G', 'o', 'o', 'g', 'l', 'e'}
bs := []byte("Golang")
hdr := (*reflect.SliceHeader)(unsa