From 8bdd1faf007c57e672e3f95f3ec4a00477c1e5c8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 21 Jan 2026 15:43:33 +0000 Subject: [PATCH] Add `total_consistency_lock` check in `handle_post_event_actions` We expect callers of `handle_post_event_actions` to hold a read lock on `total_consistency_lock`, and found that we forgot it in `process_pending_events` until recently. Here we add a relevant assertion to avoid such issues in the future. --- lightning/src/ln/channelmanager.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index af395154760..dafeffe98bf 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3438,6 +3438,10 @@ macro_rules! process_events_body { } if !post_event_actions.is_empty() { + // `handle_post_event_actions` may update channel state, so take the total + // consistency lock now similarly to other callers of `handle_post_event_actions`. + // Note that if it needs to wake the background processor for event handling or + // persistence it will do so directly. let _read_guard = $self.total_consistency_lock.read().unwrap(); $self.handle_post_event_actions(post_event_actions); // If we had some actions, go around again as we may have more events now @@ -14315,6 +14319,10 @@ where } fn handle_post_event_actions>(&self, actions: I) { + debug_assert_ne!( + self.total_consistency_lock.held_by_thread(), + LockHeldState::NotHeldByThread + ); for action in actions.into_iter() { match action { EventCompletionAction::ReleaseRAAChannelMonitorUpdate {