-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
dbg! prints can tear in multi-threading code #136703
Copy link
Copy link
Closed
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.WG-debuggingWorking group: Bad Rust debugging experiencesWorking group: Bad Rust debugging experiences
Metadata
Metadata
Assignees
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.WG-debuggingWorking group: Bad Rust debugging experiencesWorking group: Bad Rust debugging experiences
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is technically not a bug, but simply a rather frustrating behavior. If you write
dbg!(a, b), then the implementation doesn't take a lock onstderrfor the entire debug print, but foraandbseparately. This means that they can tear with other (debug) prints on stderr. E.g. if you haveYou can see the output (or various other interleavings, it gets worse with more statements and more threads)
A workaround is to use
dbg!((a, b))but I'd rather we just fix the implementation to take a lock once for the entiredbg!call to make the entire debug print atomic.