core-lightning/lightningd
Rusty Russell 2e06d814e5 lightningd: fix false positive in leak detection.
We ask each channeld to report its leaks, and keep a refcount of how
many are outstanding.  When the channeld replies, or dies, we decrement
the count in a destructor.

But if the last channeld we're waiting for dies, we can call the
destructor in an unexpected place, and thus run leak detection when
we were partway through some operation, which gives a false positive.
Here's a backtrace showing it:

```
0x5f93405897e3 send_backtrace
	common/daemon.c:33
0x5f93405381cf finish_report
	lightningd/memdump.c:139
0x5f93405382a0 leak_detect_req_done
	lightningd/memdump.c:172
0x5f9340705c41 notify
	ccan/ccan/tal/tal.c:243
0x5f9340705ca5 del_tree
	ccan/ccan/tal/tal.c:437
0x5f9340705ce8 del_tree
	ccan/ccan/tal/tal.c:447
0x5f93407061f3 tal_free
	ccan/ccan/tal/tal.c:532
0x5f9340563f5a subd_release_channel
	lightningd/subd.c:924
0x5f934050fb91 channel_set_owner
	lightningd/channel.c:31
0x5f9340511b84 channel_err
	lightningd/channel.c:1081
0x5f93405121a3 channel_fail_transient
	lightningd/channel.c:1095
0x5f934054e547 peer_channels_cleanup
	lightningd/peer_control.c:187
0x5f9340550411 peer_connected
	lightningd/peer_control.c:1689
0x5f9340525101 connectd_msg
	lightningd/connect_control.c:629
```

Instead, do the lightningd detection up-front, where it's in a
clean environment.

Reported-by: Shahana Farooqui
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-04 11:47:54 +02:00
..
test common/bolt12_id: new common routine for creating path secrets. 2024-08-01 12:31:48 +09:30
.gitignore Ignore all the deamon inside the git history 2021-10-28 15:51:38 +02:00
anchorspend.c lightningd: avoid crash from hsmd not signing anchor spend 2024-05-07 16:41:47 -05:00
anchorspend.h channeld: use anchors on peer's commitment(s) if we can't broadcast our own. 2023-10-27 11:19:56 +10:30
bitcoind.c lightningd: pass explicit context for bitcoind request functions. 2024-06-24 17:26:11 +09:30
bitcoind.h lightningd: pass explicit context for bitcoind request functions. 2024-06-24 17:26:11 +09:30
chaintopology.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
chaintopology.h chaintopology: free outstanding requests so we don't get responses while shutting down. 2024-06-24 17:26:11 +09:30
channel.c close: Do not publish unilateral when witnessing a close onchain 2024-07-29 17:08:33 +02:00
channel.h common: No longer support new channels without option_static_remotekey. 2024-06-19 15:54:24 +09:30
channel_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
channel_control.h common: No longer support new channels without option_static_remotekey. 2024-06-19 15:54:24 +09:30
channel_gossip.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
channel_gossip.h lightingd: corrections from Alex Myers's review. 2024-01-31 14:47:33 +10:30
channel_state.h dual-fund: add new open-commit-ready state 2023-11-02 19:32:05 +10:30
closed_channel.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
closed_channel.h lightningd: add last_stable_connection field to db, channel. 2024-01-31 14:47:33 +10:30
closing_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
closing_control.h lightningd: pass signed tx through to close callback. 2023-08-02 07:09:28 +09:30
coin_mvts.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
coin_mvts.h coin_mvt: tiny, dont import lightningd header 2022-02-07 13:02:09 +10:30
configs.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
connect_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
connect_control.h lightningd: tell connectd about all scids. 2024-07-10 13:34:00 +02:00
datastore.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
dual_open_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
dual_open_control.h common: BOLT update: option_anchors_zero_fee_htlc_tx is now simply "option_anchors". 2024-06-19 15:54:24 +09:30
feerate.c lightnind: remove deprecated feerate names. 2024-03-25 15:02:35 +10:30
feerate.h lightningd: clean up feerate handling, deprecate old terms. 2023-04-10 07:31:12 +09:30
forwards.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
forwards.h lightningd: clean up notification infrastructure. 2024-01-26 10:30:22 +10:30
gossip_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
gossip_control.h lightningd: ignore gossip messages from channeld, switch to our own. 2024-01-31 14:47:33 +10:30
gossip_generation.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
gossip_generation.h bitcoin/short_channel_id: pass by copy everywhere. 2024-03-20 13:51:48 +10:30
hsm_control.c lightningd: use tweak on node_id of different key, for createinvoicerequest. 2024-08-01 12:31:48 +09:30
hsm_control.h hsmd: rename "capabilities" flags for hsm fds to "permissions" 2023-08-08 14:31:47 +09:30
htlc_end.c common: remove type_to_string files altogther. 2024-03-20 13:51:48 +10:30
htlc_end.h channeld: don't calculate blinding shared secret, let lightningd do it. 2022-10-26 11:29:06 +10:30
htlc_set.c common: remove type_to_string files altogther. 2024-03-20 13:51:48 +10:30
htlc_set.h Makefile: use completely separate spec-derived files for EXPERIMENTAL_FEATURES 2020-09-08 09:42:00 +09:30
invoice.c common/bolt12_id: new common routine for creating path secrets. 2024-08-01 12:31:48 +09:30
invoice.h sendpays: hook into the wait subsystem. 2023-10-28 15:48:26 +10:30
io_loop_with_timers.c database: pull out database code into a new module 2022-03-05 15:03:34 +10:30
io_loop_with_timers.h lightningd/io_loop_with_timers.c: Move mainloop to its own source file, have chaintopology use it. 2019-05-31 17:57:10 +02:00
jsonrpc.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
jsonrpc.h rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
lightningd.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
lightningd.h lightningd: use tweak on node_id of different key, for createinvoicerequest. 2024-08-01 12:31:48 +09:30
log.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
log.h logging: add TRACE between DEBUG and IO 2024-05-08 21:05:49 -05:00
log_status.c lightningd/log: clean up nomenclature. 2023-07-19 19:13:57 +09:30
log_status.h lightningd/log: clean up nomenclature. 2023-07-19 19:13:57 +09:30
Makefile common/bolt12_id: new common routine for creating path secrets. 2024-08-01 12:31:48 +09:30
memdump.c lightningd: fix false positive in leak detection. 2024-08-04 11:47:54 +02:00
memdump.h lightningd: simplify memleak code. 2022-03-10 09:40:09 +10:30
notification.c core: notify plugins when a log line is emitted. 2024-05-17 13:03:12 -05:00
notification.h core: notify plugins when a log line is emitted. 2024-05-17 13:03:12 -05:00
offer.c lightningd: make the caller set invreq_metadata and invreq_payer_id for createinvoicerequest. 2024-08-01 12:31:48 +09:30
onchain_control.c onchaind: Remove key derivation involving the signer 2024-07-29 17:08:33 +02:00
onchain_control.h onchaind: remove 'is_replay' logic 2021-12-28 04:42:42 +10:30
onion_message.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
onion_message.h common: remove support for pre v0.10.2 onionmessages. 2021-12-01 05:44:28 +10:30
opening_common.c BOLT: update to include 2016 for max_htlc_cltv. 2024-05-09 16:14:23 -05:00
opening_common.h lightningd: pass disconnect flag to subd's errcb. 2023-10-23 15:48:50 +10:30
opening_control.c lightningd: don't create a second peer on stub recover if one already exists. 2024-08-04 10:48:36 +09:30
opening_control.h common: BOLT update: option_anchors_zero_fee_htlc_tx is now simply "option_anchors". 2024-06-19 15:54:24 +09:30
options.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
options.h lightningd: allow --recover to take a 64-char hex string. 2023-10-26 12:59:55 +10:30
pay.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
pay.h wallet: remove premature optimization when making payment. 2023-10-28 15:48:26 +10:30
peer_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
peer_control.h close: Do not publish unilateral when witnessing a close onchain 2024-07-29 17:08:33 +02:00
peer_fd.c subdaemons: remove gossipd fd from per-peer daemons. 2022-02-08 11:15:52 +10:30
peer_fd.h subdaemons: remove gossipd fd from per-peer daemons. 2022-02-08 11:15:52 +10:30
peer_htlcs.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
peer_htlcs.h lightningd: split up peer_htlcs a little, create forwards.c 2023-10-28 15:48:26 +10:30
ping.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
plugin.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
plugin.h lightningd: allow plugins to specify cancheck for us to pass check commands through. 2024-05-06 20:51:19 -05:00
plugin_control.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
plugin_control.h plugins: add command field to subcommand output. 2021-06-25 09:49:33 +09:30
plugin_hook.c logging: move two noisy plugin_hook logging entries to TRACE 2024-05-08 21:05:49 -05:00
plugin_hook.h plugin: wire JSON id for commands which caused hooks to fire. 2022-09-16 12:31:45 +09:30
routehint.c global: fix up quotes which are now in the master branch. 2024-05-09 16:14:23 -05:00
routehint.h invoice: overhaul routehints to use topology.listincoming, cleanup. 2021-06-16 10:29:17 +09:30
runes.c wire: rename "offer_node_id" to "offer_issuer_id" to match latest BOLT. 2024-08-01 12:31:48 +09:30
runes.h runes: ensure that uniqueid is a valid number. 2023-09-12 15:19:02 +09:30
signmessage.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
subd.c pyln-testing: use DEBUG_LIGHTNINGD to start gdb on lightningd during test. 2024-03-20 11:18:36 +10:30
subd.h lightningd: pass disconnect flag to subd's errcb. 2023-10-23 15:48:50 +10:30
wait.c rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
wait.h lightningd: hook forwards into the wait system. 2023-10-28 15:48:26 +10:30
watch.c common: remove type_to_string files altogther. 2024-03-20 13:51:48 +10:30
watch.h lightningd: make watch_txid more generic. 2023-10-02 11:41:19 +10:30