Fix spurious BROKEN frames on musl-based Linux stacks#2437
Merged
brianrob merged 1 commit intoJun 24, 2026
Conversation
On musl distros (e.g. Alpine) libc and the dynamic loader are combined into a single module named like ld-musl-x86_64.so.1, where threads start. Treat it as a valid top frame so musl stacks aren't marked BROKEN, mirroring the existing glibc libc handling. Add an in-memory nettrace unit test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
leculver
approved these changes
Jun 24, 2026
brianrob
enabled auto-merge
June 24, 2026 22:01
This was referenced Jul 18, 2026
Open
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Traces captured with one-collect on musl-based Linux distros (e.g. Alpine) show a large fraction of stacks marked BROKEN when opened in PerfView or TraceEvent. On a real Alpine trace, about 18% of samples were broken. The root cause is that thread base frames on musl live in the combined libc + dynamic loader module, named like
ld-musl-x86_64.so.1, whichReasonableTopFramedid not recognize as a legitimate thread-start module. We already special-case glibc'slibcfor the same reason; musl was simply missing.What
TraceEventStacks.cs: InReasonableTopFrame, treat any module whose name starts withld-musl-(case-insensitive, so it coversx86_64,aarch64, etc.) as a valid top frame, mirroring the existing glibclibchandling. When matched, a stack rooted there is no longer wrapped in a BROKEN frame.Added
Universal/MuslBrokenStackTests.cs: a unit test that synthesizes a tiny in-memory V6 nettrace (no large trace binary added to the repo) containing a musl loader module, an ordinary library, and two cpu samples: one rooted in the musl module and one rooted in the ordinary library. It asserts the musl-rooted stack is not BROKEN while the ordinary-library-rooted stack still is, parameterized over bothld-musl-x86_64.so.1andld-musl-aarch64.so.1.Validation
Notes for reviewers
The negative-case assertion (ordinary library still BROKEN) is intentional to guard against the match being too broad. The test writer emits a non-zero
syncTimeQPCso iterating relative timestamps does not trip a Debug.Assert inQPCTimeToRelMSec; this is a test-harness detail only.