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

@@ -159,9 +159,10 @@ static void check_plugins_manifests(struct plugins *plugins)
}
/* As startup, we break out once all getmanifest are returned */
if (plugins->startup)
if (plugins->startup) {
log_debug(plugins->ld->log, "io_break: %s", __func__);
io_break(plugins);
else
} else
/* Otherwise we go straight into configuring them */
plugins_config(plugins);
}
@@ -214,8 +215,10 @@ static void destroy_plugin(struct plugin *p)
/* Daemon shutdown overrules plugin's importance; aborts init checks */
if (p->plugins->ld->state == LD_STATE_SHUTDOWN) {
/* But return if this was the last plugin! */
if (list_empty(&p->plugins->plugins))
if (list_empty(&p->plugins->plugins)) {
log_debug(p->plugins->ld->log, "io_break: %s", __func__);
io_break(destroy_plugin);
}
return;
}
@@ -1761,8 +1764,12 @@ void plugins_init(struct plugins *plugins)
setenv("LIGHTNINGD_PLUGIN", "1", 1);
setenv("LIGHTNINGD_VERSION", version(), 1);
if (plugins_send_getmanifest(plugins))
io_loop_with_timers(plugins->ld);
if (plugins_send_getmanifest(plugins)) {
void *ret;
ret = io_loop_with_timers(plugins->ld);
log_debug(plugins->ld->log, "io_loop_with_timers: %s", __func__);
assert(ret == plugins);
}
}
static void plugin_config_cb(const char *buffer,
@@ -2058,6 +2065,7 @@ void *plugins_exclusive_loop(struct plugin **plugins)
/* We don't service timers here, either! */
ret = io_loop(NULL, NULL);
log_debug(plugins[0]->plugins->ld->log, "io_loop: %s", __func__);
for (i = 0; i < tal_count(plugins); ++i) {
io_conn_out_exclusive(plugins[i]->stdin_conn, false);