Make `debug_sync` regex more robust 2022-01-lockorder-windows-robust
authorMatt Corallo <git@bluematt.me>
Tue, 10 Jan 2023 06:37:39 +0000 (06:37 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 10 Jan 2023 06:48:04 +0000 (06:48 +0000)
On windows the symbol names appear to sometimes be truncated,
which causes the symbol name to not include the `::new` at the end.
This causes the regex to mis-match and track the wrong location
for the mutex construction, leading to bogus lockorder violations.

For example, in testing the following symbol name appeared on
Windows, without the function name itself:

`lightning::debug_sync::RwLock<std::collections::hash::map::HashMap<lightning::chain::transaction::OutPoint,lightning::chain::chainmonitor::MonitorHolder<lightning::util::enforcing_trait_impls::EnforcingSigner>,std::collections::hash::map::RandomState> >::`

lightning/src/sync/debug_sync.rs

index ac82475f964b4e38faf17463ce9772a4c053d1cd..9f7caa2c1804350818a5804f49fb0896c6d33f0f 100644 (file)
@@ -77,7 +77,7 @@ fn get_construction_location(backtrace: &Backtrace) -> String {
        // Find the first frame that is after `debug_sync` (or that is in our tests) and use
        // that as the mutex construction site. Note that the first few frames may be in
        // the `backtrace` crate, so we have to ignore those.
-       let sync_mutex_constr_regex = regex::Regex::new(r"lightning.*debug_sync.*new").unwrap();
+       let sync_mutex_constr_regex = regex::Regex::new(r"lightning.*debug_sync").unwrap();
        let mut found_debug_sync = false;
        for frame in backtrace.frames() {
                for symbol in frame.symbols() {