Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Crash reports: a freeze's dump is the freeze's, even when the window has recovered (#420) (#431)

Ahmed Nefzaoui2b9d8a1c0aba
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0ed0904b..6934610f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- Crash reports: a freeze whose window had recovered by the time its dump was taken is reported as a freeze, not as a crash in MDM's own watchdog ([#420](https://github.com/anefzaoui/misterdownloadmanager/issues/420)).
- Text in a script outside the interface language (a video title in Bangla, a playlist in Japanese) now shows its letters, instead of boxes: the font for that script is loaded the first time it is needed ([#405](https://github.com/anefzaoui/misterdownloadmanager/issues/405)).
- Options → Proxy / Socks now applies to yt-dlp and gallery-dl too, so video look-ups and downloads no longer go straight out when a proxy is set ([#363](https://github.com/anefzaoui/misterdownloadmanager/issues/363)).
- The window no longer freezes while watching the clipboard when the program holding it hangs, or while a cancelled download's files are removed from a slow disk ([#418](https://github.com/anefzaoui/misterdownloadmanager/issues/418), [#423](https://github.com/anefzaoui/misterdownloadmanager/issues/423)).
diff --git a/ROADMAP.md b/ROADMAP.md
index 1758e06d..cfe99d43 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -13,6 +13,8 @@ Everything below ships together, in version 0.5.0.
### Done
+- ✅ A freeze that was over before its dump was taken is reported as a freeze, not a crash in the
+ watchdog (part of [#420](https://github.com/anefzaoui/misterdownloadmanager/issues/420))
- ✅ File names and titles in any script show their letters: the system font for a script
outside the interface language loads the first time it is needed, instead of boxes
([#405](https://github.com/anefzaoui/misterdownloadmanager/issues/405))
diff --git a/crates/crash/src/monitor.rs b/crates/crash/src/monitor.rs
index ee764ffd..6a4b04a4 100644
--- a/crates/crash/src/monitor.rs
+++ b/crates/crash/src/monitor.rs
@@ -82,6 +82,9 @@ impl minidumper::ServerHandler for Handler {
) -> minidumper::LoopAction {
let notes = self.notes();
let kind = notes.dump_kind();
+ if let Ok(mut n) = self.notes.lock() {
+ n.dump_done();
+ }
match result {
Ok(mut bin) => {
use std::io::Write;
diff --git a/crates/crash/src/protocol.rs b/crates/crash/src/protocol.rs
index af1d3600..654f67b6 100644
--- a/crates/crash/src/protocol.rs
+++ b/crates/crash/src/protocol.rs
@@ -128,6 +128,9 @@ pub struct Notes {
pub state: Option<AppState>,
pub recovered: bool,
pub clean: bool,
+ /// A freeze was announced and its dump hasn't arrived yet: every freeze is followed by its
+ /// own dump, however long the window took to answer meanwhile (#420).
+ pub freeze_dump_due: bool,
}
impl Notes {
@@ -140,6 +143,7 @@ impl Notes {
kind::FREEZE => {
self.freeze = serde_json::from_slice(body).ok();
self.recovered = false;
+ self.freeze_dump_due = true;
}
kind::RECOVERED => self.recovered = true,
kind::CLEAN => self.clean = true,
@@ -148,23 +152,41 @@ impl Notes {
}
}
- /// The kind of a dump that just arrived: a panic or a freeze said so first; else a native
- /// crash.
+ /// The kind of a dump that just arrived: a panic or a freeze said so first (a freeze's dump
+ /// is the freeze's even when the window recovered before the dump was taken, #420: it was
+ /// reported as a crash in the watchdog then); else a native crash.
pub fn dump_kind(&self) -> Kind {
if self.panic.is_some() {
Kind::Panic
- } else if self.freeze.is_some() && !self.recovered {
+ } else if self.freeze_dump_due || (self.freeze.is_some() && !self.recovered) {
Kind::Freeze
} else {
Kind::Crash
}
}
+
+ /// A dump was written, or failed: a freeze's dump isn't owed any more.
+ pub fn dump_done(&mut self) {
+ self.freeze_dump_due = false;
+ }
}
#[cfg(test)]
mod tests {
use super::*;
+ /// #420: a freeze's dump is the freeze's even if the window recovered before the dump was
+ /// taken; only a later dump counts as a crash.
+ #[test]
+ fn a_freeze_dump_taken_after_recovery_is_still_the_freeze() {
+ let mut n = Notes::default();
+ n.take(kind::FREEZE, br#"{"ui_thread":7,"seconds":8}"#);
+ n.take(kind::RECOVERED, b"");
+ assert_eq!(n.dump_kind(), Kind::Freeze);
+ n.dump_done();
+ assert_eq!(n.dump_kind(), Kind::Crash, "a later dump is a real crash");
+ }
+
#[test]
fn notes_follow_the_messages() {
let mut n = Notes::default();
@@ -177,6 +199,9 @@ mod tests {
n.take(kind::FREEZE, br#"{"ui_thread":7,"seconds":9}"#);
assert_eq!(n.dump_kind(), Kind::Freeze);
n.take(kind::RECOVERED, b"");
+ // Its dump is still due: it's the freeze's (see the test below).
+ assert_eq!(n.dump_kind(), Kind::Freeze);
+ n.dump_done();
assert_eq!(n.dump_kind(), Kind::Crash);
n.take(
kind::PANIC,