Skip to content

Conversation

@korniltsev-grafanista
Copy link
Contributor

If I run the profiler under -race sanitizier I get the following error

fatal error: checkptr: converted pointer straddles multiple allocations

The error is false positive since the code has proper checks to not access all frames out of bounds.

This PR adds a workaround that creates a copy of the whole trace with a larger buffer (sizeof(Trace)) to make the checkptr happy.

This would simplify catching races like #899

As an alternative, I had an idea to change the Trace structure layout - split into multiple structures TraceHeader , Trace (which includes the headers and the frames). But that would require changes in the bpf code and seem slightly less C-idiomatic so I did not choose this option.

// workaround for "fatal error: checkptr: converted pointer straddles multiple allocations"
fullSizeCopy := make([]byte, unsafe.Sizeof(support.Trace{}))
copy(fullSizeCopy, raw)
return (*support.Trace)(unsafe.Pointer(unsafe.SliceData(fullSizeCopy)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to norace, this logic results in a different Trace.Hash (as the writes to raw through the pointer don't take effect) but since we don't use this hash at all anymore I opened #901 to remove it.

@christos68k christos68k merged commit b163f1c into open-telemetry:main Nov 4, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants