mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
memleak: throw away things when we're done with them
memleak was complaining about dangling refs; they were all allocated off of `cmd` but not technically unreachabe from any in-context memory. Instead we move things over to tmpctx to clean up (in the paths where we're going to move the objects out of reach via intermediate RPC call) ALSO: cleans up unused param in `lookup_invoice_desc` lightningd-1 2022-07-23T19:17:11.192Z **BROKEN** plugin-bookkeeper: MEMLEAK: 0x1511f68 lightningd-1 2022-07-23T19:17:11.194Z **BROKEN** plugin-bookkeeper: label=plugins/bkpr/recorder.c:1048:struct account lightningd-1 2022-07-23T19:17:11.194Z **BROKEN** plugin-bookkeeper: backtrace: lightningd-1 2022-07-23T19:17:11.194Z **BROKEN** plugin-bookkeeper: ccan/ccan/tal/tal.c:442 (tal_alloc_) lightningd-1 2022-07-23T19:17:11.194Z **BROKEN** plugin-bookkeeper: plugins/bkpr/recorder.c:1048 (stmt2account) lightningd-1 2022-07-23T19:17:11.194Z **BROKEN** plugin-bookkeeper: plugins/bkpr/recorder.c:1109 (find_account) lightningd-1 2022-07-23T19:17:11.196Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1606 (parse_and_log_channel_move) lightningd-1 2022-07-23T19:17:11.197Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1713 (json_coin_moved) lightningd-1 2022-07-23T19:17:11.198Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1421 (ld_command_handle) lightningd-1 2022-07-23T19:17:11.198Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1491 (ld_read_json_one) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1511 (ld_read_json) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:59 (next_plan) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:407 (do_plan) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:417 (io_ready) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/poll.c:453 (io_loop) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1708 (plugin_main) lightningd-1 2022-07-23T19:17:11.199Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1812 (main) lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: ../csu/libc-start.c:308 (__libc_start_main) lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: parents: lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1378:struct command lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: MEMLEAK: 0x15305b8 lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: label=plugins/bkpr/bookkeeper.c:1643:enum mvt_tag[] lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: backtrace: lightningd-1 2022-07-23T19:17:11.200Z **BROKEN** plugin-bookkeeper: ccan/ccan/tal/tal.c:442 (tal_alloc_) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: ccan/ccan/tal/tal.c:471 (tal_alloc_arr_) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1643 (parse_tags) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1686 (json_coin_moved) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1421 (ld_command_handle) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1491 (ld_read_json_one) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1511 (ld_read_json) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:59 (next_plan) lightningd-1 2022-07-23T19:17:11.201Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:407 (do_plan) lightningd-1 2022-07-23T19:17:11.202Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:417 (io_ready) lightningd-1 2022-07-23T19:17:11.202Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/poll.c:453 (io_loop) lightningd-1 2022-07-23T19:17:11.202Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1708 (plugin_main) lightningd-1 2022-07-23T19:17:11.203Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1812 (main) lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: ../csu/libc-start.c:308 (__libc_start_main) lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: parents: lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1378:struct command lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: MEMLEAK: 0x1508da8 lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: label=plugins/bkpr/bookkeeper.c:1568:struct channel_event lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: backtrace: lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: ccan/ccan/tal/tal.c:442 (tal_alloc_) lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1568 (parse_and_log_channel_move) lightningd-1 2022-07-23T19:17:11.204Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1713 (json_coin_moved) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1421 (ld_command_handle) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1491 (ld_read_json_one) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1511 (ld_read_json) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:59 (next_plan) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:407 (do_plan) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/io.c:417 (io_ready) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: ccan/ccan/io/poll.c:453 (io_loop) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1708 (plugin_main) lightningd-1 2022-07-23T19:17:11.205Z **BROKEN** plugin-bookkeeper: plugins/bkpr/bookkeeper.c:1812 (main) lightningd-1 2022-07-23T19:17:11.206Z **BROKEN** plugin-bookkeeper: ../csu/libc-start.c:308 (__libc_start_main) lightningd-1 2022-07-23T19:17:11.206Z **BROKEN** plugin-bookkeeper: parents: lightningd-1 2022-07-23T19:17:11.206Z **BROKEN** plugin-bookkeeper: plugins/libplugin.c:1378:struct command
This commit is contained in:
parent
2f72bbbbc5
commit
c83c1521ce
1 changed files with 18 additions and 15 deletions
|
@ -1231,11 +1231,12 @@ listsendpays_done(struct command *cmd, const char *buf,
|
|||
|
||||
static struct command_result *lookup_invoice_desc(struct command *cmd,
|
||||
struct amount_msat credit,
|
||||
struct amount_msat debit,
|
||||
struct sha256 *payment_hash)
|
||||
struct sha256 *payment_hash STEALS)
|
||||
{
|
||||
struct out_req *req;
|
||||
|
||||
/* Otherwise will go away when event is cleaned up */
|
||||
notleak(tal_steal(cmd, payment_hash));
|
||||
if (!amount_msat_zero(credit))
|
||||
req = jsonrpc_request_start(cmd->plugin, cmd,
|
||||
"listinvoices",
|
||||
|
@ -1265,8 +1266,6 @@ listpeers_done(struct command *cmd, const char *buf,
|
|||
struct acct_balance **balances, *bal;
|
||||
struct amount_msat credit_diff, debit_diff;
|
||||
const char *err;
|
||||
/* Make sure to clean up when we're done */
|
||||
tal_steal(cmd, info);
|
||||
|
||||
if (new_missed_channel_account(cmd, buf, result,
|
||||
info->acct,
|
||||
|
@ -1314,10 +1313,12 @@ listpeers_done(struct command *cmd, const char *buf,
|
|||
plugin_err(cmd->plugin, err);
|
||||
|
||||
if (info->ev->payment_id &&
|
||||
streq(info->ev->tag, mvt_tag_str(INVOICE)))
|
||||
streq(info->ev->tag, mvt_tag_str(INVOICE))) {
|
||||
/* Make memleak happy */
|
||||
tal_steal(tmpctx, info);
|
||||
return lookup_invoice_desc(cmd, info->ev->credit,
|
||||
info->ev->debit,
|
||||
info->ev->payment_id);
|
||||
}
|
||||
|
||||
return notification_handled(cmd);
|
||||
}
|
||||
|
@ -1435,20 +1436,20 @@ parse_and_log_chain_move(struct command *cmd,
|
|||
}
|
||||
|
||||
db_begin_transaction(db);
|
||||
acct = find_account(cmd, db, acct_name);
|
||||
acct = find_account(tmpctx, db, acct_name);
|
||||
|
||||
if (!acct) {
|
||||
/* FIXME: lookup the peer id for this channel! */
|
||||
acct = new_account(cmd, acct_name, NULL);
|
||||
acct = new_account(tmpctx, acct_name, NULL);
|
||||
account_add(db, acct);
|
||||
}
|
||||
|
||||
if (e->origin_acct) {
|
||||
orig_acct = find_account(cmd, db, e->origin_acct);
|
||||
orig_acct = find_account(tmpctx, db, e->origin_acct);
|
||||
/* Go fetch the originating account
|
||||
* (we might not have it) */
|
||||
if (!orig_acct) {
|
||||
orig_acct = new_account(cmd, e->origin_acct, NULL);
|
||||
orig_acct = new_account(tmpctx, e->origin_acct, NULL);
|
||||
account_add(db, orig_acct);
|
||||
}
|
||||
} else
|
||||
|
@ -1506,7 +1507,7 @@ parse_and_log_chain_move(struct command *cmd,
|
|||
" Calling `listpeers` to fetch missing info",
|
||||
acct->name);
|
||||
|
||||
info = tal(NULL, struct event_info);
|
||||
info = tal(cmd, struct event_info);
|
||||
info->ev = tal_steal(info, e);
|
||||
info->acct = tal_steal(info,
|
||||
is_channel_account(acct) ?
|
||||
|
@ -1532,8 +1533,9 @@ parse_and_log_chain_move(struct command *cmd,
|
|||
if (tags[i] != INVOICE)
|
||||
continue;
|
||||
|
||||
/* Keep memleak happy */
|
||||
tal_steal(tmpctx, e);
|
||||
return lookup_invoice_desc(cmd, e->credit,
|
||||
e->debit,
|
||||
e->payment_id);
|
||||
}
|
||||
}
|
||||
|
@ -1591,7 +1593,7 @@ parse_and_log_channel_move(struct command *cmd,
|
|||
|
||||
/* Go find the account for this event */
|
||||
db_begin_transaction(db);
|
||||
acct = find_account(cmd, db, acct_name);
|
||||
acct = find_account(tmpctx, db, acct_name);
|
||||
if (!acct)
|
||||
plugin_err(cmd->plugin,
|
||||
"Received channel event,"
|
||||
|
@ -1607,8 +1609,9 @@ parse_and_log_channel_move(struct command *cmd,
|
|||
if (tags[i] != INVOICE)
|
||||
continue;
|
||||
|
||||
/* Keep memleak happy */
|
||||
tal_steal(tmpctx, e);
|
||||
return lookup_invoice_desc(cmd, e->credit,
|
||||
e->debit,
|
||||
e->payment_id);
|
||||
}
|
||||
}
|
||||
|
@ -1671,7 +1674,7 @@ static struct command_result *json_coin_moved(struct command *cmd,
|
|||
err, json_tok_full_len(params),
|
||||
json_tok_full(buf, params));
|
||||
|
||||
err = parse_tags(cmd, buf,
|
||||
err = parse_tags(tmpctx, buf,
|
||||
json_get_member(buf, params, "coin_movement"),
|
||||
&tags);
|
||||
if (err)
|
||||
|
|
Loading…
Add table
Reference in a new issue