-
Notifications
You must be signed in to change notification settings - Fork 10
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
[crashtracker] Enable client to configure which signals to trap #856
base: main
Are you sure you want to change the base?
Conversation
SigHandler::Handler(f) => f(signum), | ||
SigHandler::SigAction(f) => f(signum, sig_info, ucontext), | ||
}; | ||
eprintln!("Unexpected signal number {signum}, can't chain the handlers"); |
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.
What should we do here? abort?
unsafe { create_alt_stack()? }; | ||
} | ||
let mut old_handlers = HashMap::new(); | ||
// TODO: if this fails, we end in a situation where handlers have been registered with no chain |
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.
What to do here?
let boxed_ptr = Box::into_raw(Box::new(old_handlers)); | ||
|
||
let res = OLD_HANDLERS.compare_exchange(ptr::null_mut(), boxed_ptr, SeqCst, SeqCst); | ||
anyhow::ensure!( |
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.
This leaks the old_handlers, if we care?
@@ -674,9 +665,11 @@ pub fn restore_old_handlers(inside_signal_handler: bool) -> anyhow::Result<()> { | |||
anyhow::ensure!(!prev.is_null(), "No crashtracking previous signal handlers"); | |||
// Safety: The only nonnull pointer stored here comes from Box::into_raw() | |||
let prev = unsafe { Box::from_raw(prev) }; |
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.
We could flip this around, and only rehydrate into a box when we are ready to drop it
BenchmarksComparisonBenchmark execution time: 2025-02-07 21:47:55 Comparing candidate commit ab7383e in PR branch Found 0 performance improvements and 4 performance regressions! Performance is the same for 48 metrics, 2 unstable metrics. scenario:credit_card/is_card_number/37828224631000521389798
scenario:credit_card/is_card_number_no_luhn/37828224631000521389798
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. |
before_len == signals.len(), | ||
"Signals contained duplicate elements" | ||
); | ||
|
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.
Could also check that the ints are valid here?
ddog_crasht_Config config = { | ||
.create_alt_stack = false, | ||
.endpoint = endpoint, | ||
.resolve_frames = DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_INPROCESS_SYMBOLS, | ||
.signals = INIT_FROM_SLICE(signals), |
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.
Is there a nicer way to do this?
8050f45
to
90442a0
Compare
@@ -320,6 +328,7 @@ fn test_altstack_use_create() -> anyhow::Result<()> { | |||
eprintln!("Expected SIGSEGV handler to have SA_ONSTACK"); | |||
std::process::exit(-9); | |||
} | |||
// TODO, the other signals |
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.
Reminder to myself
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #856 +/- ##
==========================================
- Coverage 72.08% 71.81% -0.28%
==========================================
Files 323 323
Lines 47941 48207 +266
==========================================
+ Hits 34560 34618 +58
- Misses 13381 13589 +208
|
One thing I strongly recommend is: let's put in some defaults! In past features "leaving it up to implementer" often meant unintended inconsistency as things get picked semi-randomly; I think in general it's nice to have a pattern of "if you don't want to choose, we pick a reasonable default, don't worry about it". |
https://github.com/DataDog/libdatadog/pull/856/files#diff-fded76796d1b1945fd14d3cdb6230e4692e94608fc4887d26e2530a004df451aR59 |
Ahaha my bad for scrolling too fast through the PR, and amazing work in getting this in :D :D :D |
What does this PR do?
Instead of hardcoding the signals to trap, allow the client to specify them
Motivation
We wanted to catch sigabort and sigill in addition to sigsegv and sigbus, and I figured lets just make it generic.
Additional Notes
Anything else we should know when reviewing?
How to test the change?