Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanups (extracted from autoclean rework) #5577

Merged
merged 9 commits into from
Sep 12, 2022

Commits on Sep 8, 2022

  1. lightningd: fix crash with -O3 -flto.

    It's foolish to ban passing NULL, 0 to memcpy, memset et al, but
    it's been done.  At high level of optimization, GCC assumes this doesn't
    happen, and yep, assumes "if (ctx)" inside tal_free() must be true.
    
    So when a psbt is NULL, and psbt_get_bytes returns NULL, a crash ensues:
    
    ```
    lightningd: FATAL SIGNAL 6 (version v0.12.0rc2-6-g47efa5d-modded)
    0x5557dfc42fef send_backtrace
    	common/daemon.c:33
    0x5557dfc42fef crashdump
    	common/daemon.c:46
    0x7fe93ef5851f ???
    	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
    0x7fe93efaca7c __pthread_kill_implementation
    	./nptl/pthread_kill.c:44
    0x7fe93efaca7c __pthread_kill_internal
    	./nptl/pthread_kill.c:78
    0x7fe93efaca7c __GI___pthread_kill
    	./nptl/pthread_kill.c:89
    0x7fe93ef58475 __GI_raise
    	../sysdeps/posix/raise.c:26
    0x7fe93ef3e7f2 __GI_abort
    	./stdlib/abort.c:79
    0x5557dfbb0c28 call_error
    	ccan/ccan/tal/tal.c:93
    0x5557dfbb0c34 check_bounds
    	ccan/ccan/tal/tal.c:165
    0x5557dfbb0c34 to_tal_hdr
    	ccan/ccan/tal/tal.c:178
    0x5557dfc7a1d3 tal_free
    	ccan/ccan/tal/tal.c:482
    0x5557dfc609d3 tal_free
    	ccan/ccan/tal/tal.c:477
    0x5557dfc609d3 towire_wally_psbt
    	bitcoin/psbt.c:743
    0x5557dfbc5dfc towire_dualopend_got_offer_reply
    	openingd/dualopend_wiregen.c:358
    0x5557dfbc5dfc openchannel2_hook_cb
    	lightningd/dual_open_control.c:671
    0x5557dfc22f4f plugin_hook_callback
    	lightningd/plugin_hook.c:210
    0x5557dfc1dfbe plugin_response_handle
    	lightningd/plugin.c:591
    0x5557dfc1dfbe plugin_read_json_one
    	lightningd/plugin.c:702
    0x5557dfc1dfbe plugin_read_json
    	lightningd/plugin.c:747
    0x5557dfc71756 next_plan
    	ccan/ccan/io/io.c:59
    0x5557dfc775d5 io_ready
    	ccan/ccan/io/io.c:417
    0x5557dfc775d5 io_loop
    	ccan/ccan/io/poll.c:453
    0x5557dfbdb1ce io_loop
    	ccan/ccan/io/poll.c:380
    0x5557dfbdb1ce io_loop_with_timers
    	lightningd/io_loop_with_timers.c:22
    0x5557dfbb37d1 main
    	lightningd/lightningd.c:1195
    0x7fe93ef3fd8f __libc_start_call_main
    	../sysdeps/nptl/libc_start_call_main.h:58
    0x7fe93ef3fe3f __libc_start_main_impl
    	../csu/libc-start.c:392
    0x5557dfbb6e84 ???
    	???:0
    0xffffffffffffffff ???
    	???:0
    ```
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    632fa0c View commit details
    Browse the repository at this point in the history
  2. tools/test: fix very confused code.

    This broke with COPTFLAGS="-flto -O3", and so I took a look (it
    complains more than normal because main isn't there).  We should never
    be running update-mocks except on programs expected to compile: in
    this case, that's tools/test/run-test-wire.c.
    
    Remove the code which tries to run this, which also means
    non-developers won't be running update-mocks!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    4aff912 View commit details
    Browse the repository at this point in the history
  3. db: fix renaming/deleting cols of DBs when there are UNIQUE(x, b, c) …

    …constraints.
    
    Get stricter with recognizing real column defs.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    0962255 View commit details
    Browse the repository at this point in the history
  4. doc: escape output types (esp short_channel_id).

    We can also remove the listpeers closer hack, which was removed from
    the schema already.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    78c4e44 View commit details
    Browse the repository at this point in the history
  5. libplugin: allow NULL calllbacks for jsonrpc_set_datastore.

    You often don't care about the reply, so this is quite convenient.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    010b202 View commit details
    Browse the repository at this point in the history
  6. doc: disallow additional properties in sendcustommsg.

    We have to scatter this everywhere in our schemas, as there's no way
    to make it the default :(
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    9e33e23 View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2022

  1. db: fix migrations which write to db.

    valgrind noticed that this was uninitialized when I tried a complex
    migration.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 9, 2022
    Configuration menu
    Copy the full SHA
    dbab4fc View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2022

  1. db: fix sqlite3 code which manipulates columns.

    Because it used internal routines, it didn't pass operations through the
    db hook!  So make it use the generic routines, with the twist that they
    are not translated.
    
    And when we use this in a migration hook, we're actually in a
    transaction.
    
    This, in turn, introduces an issue: we need to be outside a transaction
    to "PRAGMA foreign_keys = OFF", but completing the transaction when
    there is a db hook actually enters the io loop, freeing the tmpctx!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 11, 2022
    Configuration menu
    Copy the full SHA
    e00d323 View commit details
    Browse the repository at this point in the history
  2. lightningd: more graceful shutdown.

    Be more graceful in shutting down: this should fix the issue where
    bookkeeper gets upset that its commands are rejected during shutdown,
    and generally make things more graceful.
    
    1. Stop any new RPC connections.
    2. Stop any per-peer daemons (channeld, etc).
    3. Shut down plugins.
    4. Stop all existing RPC connections.
    5. Stop global daemons.
    6. Free up peer, chanen HTLC datastructures.
    7. Close database.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Changed: Plugins: RPC operations are now still available during shutdown.
    rustyrussell committed Sep 11, 2022
    Configuration menu
    Copy the full SHA
    e7fe59b View commit details
    Browse the repository at this point in the history