-
Notifications
You must be signed in to change notification settings - Fork 13
[crashtracker] Prevent crashtracker from deadlocking #1111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
BenchmarksComparisonBenchmark execution time: 2025-06-17 08:10:03 Comparing candidate commit 8eb0506 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
bf4ce2c
to
4a3fcbe
Compare
4a3fcbe
to
8eb0506
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1111 +/- ##
==========================================
+ Coverage 70.97% 71.00% +0.03%
==========================================
Files 336 336
Lines 51191 51194 +3
==========================================
+ Hits 36332 36350 +18
+ Misses 14859 14844 -15
🚀 New features to boost your workflow:
|
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good assuming that the thing we want is going to fit in the first 8K of the file. Otherwise we gotta figure out how to loop or something else.
Also, is 8k too much space on the stack?
Yeah, I did not want to make the complex more complex directly. Generally
maybe, it was to take care of the case where the file is big. I can make it 4k if you think it would be safer. |
// This function may run in signal handler, so we should ensure that we do not allocate | ||
// memory on the heap (ex: avoiding using BufReader for exao). | ||
let mut file = File::open("/proc/self/status")?; | ||
let mut buf = [0u8; 8192]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how long do we expect the file to be, worst case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general it's less than 4KB, a pathological case would be 8-10KB but I've never seen such thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would there be value in looping if there are still bytes left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I do not know, my main goal is to avoid calling malloc here as simple as I can.
going for looping would make thing more complex and we sufficient space, I feel like it won't be necessary.
WDYT ?
let data = &buf[..n]; | ||
|
||
for line in data.split(|&b| b == b'\n') { | ||
if let Ok(line_str) = std::str::from_utf8(line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IF this fails, should we return false, or an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question would be what should we do on error.
Today, the semantic is:
Ok(true)
: useCLONE_PTRACE
as an extra-flagsOk(false)
: use0
to specify no clone flags
Should an error have the same behavior as Ok(false)
or should be stop and no crash report is generated ?
All that said, I would say, we are fine today :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would continue. Best effort is all we can do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so keep it like that
Is there a specific reason this hasn't been merged yet? @gleocadie |
What does this PR do?
Prevent crashtracker from deadlocking when calling
is_being_traced
function.Motivation
We got a recent report with this callstack (shorten):
As you can see, an allocation is done while running in the signal handler. As shown in this case, this causes a deadlock: application gets stuck.
This happens (as seen in the callstack),
BufReader::new
allocates. This is done here.To avoid that, we need a zero-heap-allocation version of this version.