core-lightning/lightningd
Rusty Russell df50faba6a lightningd: fix crash when plugin has been unloaded and we abort cmd.
I reproduced this by putting a sleep(60) in the pay plugin, then
'lightning-cli pay', 'lightning-cli plugin stop pay' and then ^C
the `lightning-cli pay`:

2020-02-14T00:33:11.217Z INFO plugin-pay: Killing plugin: pay stopped by lightningd via RPC
2020-02-14T00:33:15.250Z DEBUG lightningd: Still waiting for initial block download
==5157== Invalid read of size 8
==5157==    at 0x12A29C: destroy_jcon (jsonrpc.c:149)
==5157==    by 0x1C6F2A: notify (tal.c:235)
==5157==    by 0x1C7441: del_tree (tal.c:397)
==5157==    by 0x1C7493: del_tree (tal.c:407)
==5157==    by 0x1C77DD: tal_free (tal.c:481)
==5157==    by 0x1B7380: io_close (io.c:450)
==5157==    by 0x1B71A7: do_plan (io.c:401)
==5157==    by 0x1B7214: io_ready (io.c:417)
==5157==    by 0x1B94AC: io_loop (poll.c:445)
==5157==    by 0x1291C9: io_loop_with_timers (io_loop_with_timers.c:24)
==5157==    by 0x12EC7E: main (lightningd.c:928)
==5157==  Address 0x4ebab98 is 40 bytes inside a block of size 88 free'd
==5157==    at 0x483BA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==5157==    by 0x1C750F: del_tree (tal.c:416)
==5157==    by 0x1C7493: del_tree (tal.c:407)
==5157==    by 0x1C77DD: tal_free (tal.c:481)
==5157==    by 0x153856: clear_plugin (plugin_control.c:209)
==5157==    by 0x1538FF: plugin_dynamic_stop (plugin_control.c:225)
==5157==    by 0x153C51: json_plugin_control (plugin_control.c:295)
==5157==    by 0x12B4EC: command_exec (jsonrpc.c:588)
==5157==    by 0x12B8AB: rpc_command_hook_callback (jsonrpc.c:679)
==5157==    by 0x154575: plugin_hook_call_ (plugin_hook.c:170)
==5157==    by 0x12BCD3: plugin_hook_call_rpc_command (jsonrpc.c:756)
==5157==    by 0x12BD04: call_rpc_command_hook (jsonrpc.c:764)
==5157==  Block was alloc'd at
==5157==    at 0x483A7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==5157==    by 0x1C6F98: allocate (tal.c:245)
==5157==    by 0x1C7559: tal_alloc_ (tal.c:423)
==5157==    by 0x15135A: plugin_rpcmethod_add (plugin.c:706)
==5157==    by 0x151600: plugin_rpcmethods_add (plugin.c:756)
==5157==    by 0x151BDD: plugin_parse_getmanifest_response (plugin.c:893)
==5157==    by 0x151C9C: plugin_manifest_cb (plugin.c:915)
==5157==    by 0x14FFB9: plugin_response_handle (plugin.c:258)
==5157==    by 0x150165: plugin_read_json_one (plugin.c:356)
==5157==    by 0x1502BC: plugin_read_json (plugin.c:388)
==5157==    by 0x1B65ED: next_plan (io.c:59)
==5157==    by 0x1B71D2: do_plan (io.c:407)

Fixes: #3509
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-15 08:49:18 +10:30
..
test lightningd/bitcoind: use the Bitcoin plugin for getutxout 2020-02-12 11:45:07 +10:30
.gitignore
bitcoind.c pytest: test Bitcoin plugin registration and the bcli plugin 2020-02-12 11:45:07 +10:30
bitcoind.h lightningd/bitcoind: remove all bitcoin-cli specific code 2020-02-12 11:45:07 +10:30
chaintopology.c pytest: test Bitcoin plugin registration and the bcli plugin 2020-02-12 11:45:07 +10:30
chaintopology.h lightningd/bitcoind: use the Bitcoin plugin to send transactions 2020-02-12 11:45:07 +10:30
channel_control.c lightningd/bitcoind: use the Bitcoin plugin for getutxout 2020-02-12 11:45:07 +10:30
channel_control.h channel control: break out separate method for canceling 2020-02-10 15:59:26 +10:30
channel_state.h
channel.c lightningd: save the fee_states into the database. 2019-12-12 22:15:48 +01:00
channel.h TAGS: reformat to fix when PRINTF_FMT() used. 2019-11-01 17:27:20 -05:00
closing_control.c lightningd: save the fee_states into the database. 2019-12-12 22:15:48 +01:00
closing_control.h
connect_control.c connectd: Pass the init_featurebits down to connectd and use in init 2020-02-11 13:53:31 +10:30
connect_control.h
gossip_control.c plugin: Add featurebits registered by plugins to node_announcements 2020-02-11 13:53:31 +10:30
gossip_control.h gossipd: get fed the blockheight from lightningd when we know it. 2019-09-25 04:01:56 +00:00
gossip_msg.c gossipd: add hop-style to nodes to mark whether they speak TLV onion. 2019-11-14 10:15:33 +01:00
gossip_msg.h common/features: only support a single feature bitset. 2019-10-11 02:52:04 +00:00
hsm_control.c bitcoind: remove the chainparams member 2019-11-15 13:14:08 +01:00
hsm_control.h
htlc_end.c htlcs: remove origin_htlc_id from htlc_out. 2019-12-12 15:03:53 +01:00
htlc_end.h common: use struct onionreply. 2020-01-23 16:17:42 +10:30
htlc_set.c Makefile: update bolt markers which have been since merged. 2020-01-31 06:07:56 +00:00
htlc_set.h lightningd: remove htlc_set destruction timer once we head to invoice. 2019-12-12 22:16:03 +01:00
invoice.c plugin: Introduce plugin type to allow singleton and chaining 2020-02-11 15:57:22 +10:30
invoice.h lightningd: sew in htlc set. 2019-12-12 15:03:53 +01:00
io_loop_with_timers.c
io_loop_with_timers.h
json.c common: move json_stream helpers to common/json 2020-02-04 13:24:32 +10:30
json.h common: move json_stream helpers to common/json 2020-02-04 13:24:32 +10:30
jsonrpc.c lightningd: fix crash when plugin has been unloaded and we abort cmd. 2020-02-15 08:49:18 +10:30
jsonrpc.h common: move json_stream from lightningd/ to common/ 2020-02-04 13:24:32 +10:30
lightningd.c lightningd: clean utxos after the topology is setup 2020-02-12 11:45:07 +10:30
lightningd.h lightningd: Added --subdaemon command to allow alternate subdaemons. 2020-02-04 10:44:13 +10:30
log_status.c lightningd: kill per-peer daemons if they claim a different peer id. 2019-11-18 04:50:22 +00:00
log_status.h lightningd: have logging include an optional node_id for each entry. 2019-11-18 04:50:22 +00:00
log.c log: print UNUSUAL messages before log initialization too. 2019-11-23 22:42:34 +00:00
log.h lightningd: use a simple array for less memory usage. 2019-11-18 04:50:22 +00:00
Makefile common: move json_stream from lightningd/ to common/ 2020-02-04 13:24:32 +10:30
memdump.c htlcs: Make sure htlc_sets is not erroneously flagged as a memleak 2019-12-12 22:16:03 +01:00
memdump.h
notification.c db: put scids in forwards even if we didn't actually send. 2020-02-12 22:27:57 -06:00
notification.h db: put scids in forwards even if we didn't actually send. 2020-02-12 22:27:57 -06:00
onchain_control.c lightningd: have optional node_id associated with subdaemons. 2019-11-18 04:50:22 +00:00
onchain_control.h
opening_control.c plugin: Introduce plugin type to allow singleton and chaining 2020-02-11 15:57:22 +10:30
opening_control.h subd: Add a helper to get the current owning subd for a given peer 2020-01-28 23:50:52 +01:00
options.c lightningd/bitcoind: remove all bitcoin-cli specific code 2020-02-12 11:45:07 +10:30
options.h common: parse --allow-deprecated-apis extremely early. 2019-11-23 22:42:34 +00:00
pay.c lightningd: fix wrong command in response message 2020-02-03 15:38:11 +00:00
pay.h Use dedicated type for error codes 2020-01-31 06:02:47 +00:00
peer_control.c lightningd/bitcoind: use the Bitcoin plugin for getutxout 2020-02-12 11:45:07 +10:30
peer_control.h peer: Add custommsg hook and wire it into channeld and openingd 2020-01-28 23:50:52 +01:00
peer_htlcs.c db: put scids in forwards even if we didn't actually send. 2020-02-12 22:27:57 -06:00
peer_htlcs.h lightningd: save the fee_states into the database. 2019-12-12 22:15:48 +01:00
ping.c
ping.h
plugin_control.c lightningd/plugin: unregister a plugin's options when stopping it 2020-02-10 09:49:15 +10:30
plugin_control.h plugins: cleanup shared headers between dynamic and static plugins 2019-09-30 00:20:16 +00:00
plugin_hook.c plugin: Remove special case for plugin stopping while handling hooks 2020-02-11 15:57:22 +10:30
plugin_hook.h plugin: Multiple plugins can register a singl hook 2020-02-11 15:57:22 +10:30
plugin.c chaintopology: check bitcoin plugin commands at startup 2020-02-12 11:45:07 +10:30
plugin.h chaintopology: check bitcoin plugin commands at startup 2020-02-12 11:45:07 +10:30
signmessage.c lightningd: checkmessage can intuit pubkey in some cases. 2019-10-14 18:58:44 -05:00
subd.c lightningd: Added --subdaemon command to allow alternate subdaemons. 2020-02-04 10:44:13 +10:30
subd.h lightningd: have optional node_id associated with subdaemons. 2019-11-18 04:50:22 +00:00
watch.c wallet: remove edgecase around transaction checks 2020-01-02 16:56:42 +01:00
watch.h