lightningd: track weird CI crash in test_important_plugin

Looks like we woke one of the startup io_loops early, and thus
we thought we'd finished connectd_activate and we hadn't.  This
caused us to use an uninitialized ld->announceable array, and
finally caused an assert fail in the main loop.

Make *every* loop assert that it was exited for the correct reason,
so if it happens again, we can maybe figure out what part of
the code to look at.

```
lightningd: lightningd/lightningd.c:1186: main: Assertion `io_loop_ret == ld' failed.
lightningd: FATAL SIGNAL 6 (version 4df66fa)
...
------------------------------- Valgrind errors --------------------------------
Valgrind error file: valgrind-errors.895509
==895509== Conditional jump or move depends on uninitialised value(s)
==895509==    at 0x22C58E: to_tal_hdr_or_null (tal.c:184)
==895509==    by 0x22D531: tal_bytelen (tal.c:637)
==895509==    by 0x1F10B6: towire_gossipd_init (gossipd_wiregen.c:100)
==895509==    by 0x13AC6E: gossip_init (gossip_control.c:254)
==895509==    by 0x1497EC: main (lightningd.c:1090)
==895509== 
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-06-26 14:21:01 +09:30
parent 9137ea262b
commit 3f98cf3fce
9 changed files with 45 additions and 10 deletions

View File

@@ -332,6 +332,7 @@ static void db_hook_response(const char *buffer, const jsmntok_t *toks,
return;
/* We're done, exit exclusive loop. */
log_debug(dwh_req->plugin->plugins->ld->log, "io_break: %s", __func__);
io_break(dwh_req->ph_req);
}
@@ -392,6 +393,7 @@ void plugin_hook_db_sync(struct db *db)
if (ret != ph_req) {
void *ret2 = plugins_exclusive_loop(plugins);
assert(ret2 == ph_req);
log_debug(plugins[0]->plugins->ld->log, "io_break: %s", __func__);
io_break(ret);
}
assert(num_hooks == 0);