Repository: fujiapple852/trippy (language: rust)

Issue:
Heisenbug: trip _gateway panic sometimes
```
#trip _gateway
thread 'main' panicked at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/core/src/cmp.rs:879:9:
assertion failed: min <= max
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Unfortunately it cannot be reproduced the second time ..it happens once in a while.. I'l trry to get a backtrace ..


Discussion / hints:

Fix patch:
diff --git a/src/frontend/tui_app.rs b/src/frontend/tui_app.rs
index 66d96ab4a..7275ce867 100644
--- a/src/frontend/tui_app.rs
+++ b/src/frontend/tui_app.rs
@@ -353,7 +353,7 @@ impl TuiApp {
     pub fn expand_hosts(&mut self) {
         self.tui_config.max_addrs = match self.tui_config.max_addrs {
             None => Some(1),
-            Some(i) if i < self.max_hosts() => Some(i + 1),
+            Some(i) if Some(i) < self.max_hosts() => Some(i + 1),
             Some(i) => Some(i),
         }
     }
@@ -378,7 +378,7 @@ impl TuiApp {
     }
 
     pub fn expand_hosts_max(&mut self) {
-        self.tui_config.max_addrs = Some(self.max_hosts());
+        self.tui_config.max_addrs = self.max_hosts();
     }
 
     pub fn contract_hosts_min(&mut self) {
@@ -386,14 +386,13 @@ impl TuiApp {
     }
 
     /// The maximum number of hosts per hop for the currently selected trace.
-    pub fn max_hosts(&self) -> u8 {
+    pub fn max_hosts(&self) -> Option<u8> {
         self.selected_tracer_data
             .hops(self.selected_flow)
             .iter()
             .map(|h| h.addrs().count())
             .max()
             .and_then(|i| u8::try_from(i).ok())
-            .unwrap_or_default()
     }
 }
 


Test patch: