-
Notifications
You must be signed in to change notification settings - Fork 405
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
Print a notice when delta panics #1917
base: main
Are you sure you want to change the base?
Conversation
unsafe { | ||
std::env::set_var(RUST_BACKTRACE, "1"); | ||
} |
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.
Preparing for the 2024 edition :)
while let Some(Ok(raw_line_bytes)) = lines.next() { | ||
debug_helper.write(raw_line_bytes); | ||
|
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 IIUC, the pattern we're using is
Create the debug_helper = RecordDeltaCall::new()
; This causes some default diagnostics to be written.
...
Append additional arbitrary diagnostics via debug_helper.write
...
Terminate the file in the Drop
impl for RecordDeltaCall
.
But if the DELTA_DEBUG_LOGFILE
is not set, then, although we do a few function calls, they are all no-ops.
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.
Indeed, write()
will usually return after an an easily branch-predicted if.
src/cli.rs
Outdated
*/ | ||
#[arg(hide = true, long = "test-panic")] | ||
pub test_panic: bool, | ||
|
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 wonder whether this commit (Add --test-panic
) is more a development commit that we don't need to merge?
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 main commit LGTM (PR needs rebasing). I'm inclined to think that we don't really need the second commit in main
-- save a little complexity from our code readers's eyes.
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.
Dropped the second commit, can be merged.
while let Some(Ok(raw_line_bytes)) = lines.next() { | ||
debug_helper.write(raw_line_bytes); | ||
|
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.
Indeed, write()
will usually return after an an easily branch-predicted if.
write("git config values:\n".into())?; | ||
cfg.for_each(".*", |entry, value: Option<&str>| { | ||
if !(entry.starts_with("user.") | ||
|| entry.starts_with("remote.") | ||
|| entry.starts_with("branch.") | ||
|| entry.starts_with("gui.")) |
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.
Note: I inverted the logic, now printing all git configs (see git config --get-regexp '.*'
) except a those listed here.
src/utils/debug.rs
Outdated
|
||
write( | ||
"<details>\n\ | ||
<summary>Input which caused delta to crash</summary>\n```\n\n" |
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.
<summary>Input which caused delta to crash</summary>\n```\n\n" | |
<summary>Input which caused delta to crash</summary>\n\n```\n\n" |
In practice I believe the GitHub markdown renderer requires one blank line before the triple-backtick. E.g. compare
Input which caused delta to crash
hello
with
Input which caused delta to crash
``` hello ```Setting DELTA_DEBUG_LOGFILE=crash.log and repeating the command writes all information needed to reproduce the crash into that file.
The raw lines of course contain the usual escape characters, pasting those into an issue isn't that helpful:
This turns the escape chars into A |
Setting
DELTA_DEBUG_LOGFILE=crash.log
and repeating the commandwrites all information needed to reproduce the crash into that file.
To test the debug handler
The notice reads: