Skip to content

Commit 136248c

Browse files
committed
manual: expand useGoAllocation's comment
Document the restriction on allocating all of the manual package's allocations either via Go or via CGo, but not a combination. A combination could run afoul of CGo pointer passing rules.
1 parent 2fa0183 commit 136248c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/manual/manual_cgo.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ func throw(s string)
2525
// memory. Performing some allocations using Go allows the race detector to
2626
// observe concurrent memory access to memory allocated by this package.
2727
//
28+
// Note that we must either perform ALL allocations made by this package using
29+
// Go or none of them. We sometimes store a pointer to a buffer allocated by
30+
// this package (eg, a block) in a struct also allocated by this package (a
31+
// block cache entry). The CGo pointer passing rules require that only pinned Go
32+
// pointers are stored in CGo memory.
33+
//
2834
// TODO(jackson): Confirm that the race detector does not detect races within
2935
// cgo-allocated memory.
3036
var useGoAllocation = invariants.RaceEnabled && rand.Uint32()%2 == 0

0 commit comments

Comments
 (0)