From 4990b6bbccf6caf317bf922ccc74b5d333beb627 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 15 Jun 2018 10:42:23 +0930 Subject: [PATCH] channeld: don't crash if remote asks for unnecessary retransmit. We assume they haven't acknowledged it, but they might have (seems like a bug though). We could hang up on them, but we'll happily continue. lightning_channeld: channeld/channel.c:1702: resend_commitment: Assertion `peer->revocations_received == peer->next_index[REMOTE] - 2' failed. lightning_channeld: Fatal signal 6 0x559919c35dcd crashdump common/daemon.c:37 0x7f76d5be27ef ??? ???:0 0x7f76d5be277f ??? ???:0 0x7f76d5be4379 ??? ???:0 0x7f76d5bdab46 ??? ???:0 0x7f76d5bdabf1 ??? ???:0 0x559919c29337 resend_commitment channeld/channel.c:1702 0x559919c297cf peer_reconnect channeld/channel.c:1853 0x559919c2b3d5 init_channel channeld/channel.c:2518 0x559919c2b6f8 main channeld/channel.c:2580 0x7f76d5bcd3f0 ??? ???:0 0x559919c244d9 ??? ???:0 0xffffffffffffffff ??? ???:0 Signed-off-by: Rusty Russell --- channeld/channel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/channeld/channel.c b/channeld/channel.c index 74b360e9a..428fc8746 100644 --- a/channeld/channel.c +++ b/channeld/channel.c @@ -1703,7 +1703,13 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last enqueue_peer_msg(peer, take(msg)); tal_free(commit_sigs); - assert(peer->revocations_received == peer->next_index[REMOTE] - 2); + /* If we have already received the revocation for the previous, the + * other side shouldn't be asking for a retransmit! */ + if (peer->revocations_received != peer->next_index[REMOTE] - 2) + status_unusual("Retransmitted commitment_signed %"PRIu64 + " but they already send revocation %"PRIu64"?", + peer->next_index[REMOTE]-1, + peer->revocations_received); } /* Our local wrapper around read_peer_msg */