lightning icon indicating copy to clipboard operation
lightning copied to clipboard

listpeers crash lightning node

Open chek2fire opened this issue 7 years ago • 5 comments

Issue and Steps to Reproduce

listpeers crash my node. I have reproduce this to three of my lightning nodes. All of nodes are up and running for one year now with upgrades to newest version time2time

lightningd: bitcoin/tx.c:215: push_tx: Assertion `res == WALLY_OK && len == written' failed. lightningd: FATAL SIGNAL 6 (version v0.7.1rc2-10-g92bd3a3-modded) 0x429611 send_backtrace common/daemon.c:40 0x42969b crashdump common/daemon.c:53 0x7f127918d4af ??? ???:0 0x7f127918d428 ??? ???:0 0x7f127918f029 ??? ???:0 0x7f1279185bd6 ??? ???:0 0x7f1279185c81 ??? ???:0 0x436b20 push_tx bitcoin/tx.c:215 0x4372c4 bitcoin_txid bitcoin/tx.c:266 0x41c52e json_add_channel lightningd/peer_control.c:573 0x41cc05 json_add_peer lightningd/peer_control.c:1061 0x41d87a json_listpeers lightningd/peer_control.c:1093 0x410abb parse_request lightningd/jsonrpc.c:654 0x410c9d read_json lightningd/jsonrpc.c:752 0x45658f next_plan ccan/ccan/io/io.c:59 0x456a4f do_plan ccan/ccan/io/io.c:407 0x456a7a io_ready ccan/ccan/io/io.c:417 0x458123 io_loop ccan/ccan/io/poll.c:445 0x40e82d io_loop_with_timers lightningd/io_loop_with_timers.c:24 0x4122c5 main lightningd/lightningd.c:827 0x7f127917882f ??? ???:0 0x403da8 ??? ???:0 0xffffffffffffffff ??? ???:0 2019-06-20T14:41:19.602Z lightningd(26528): FATAL SIGNAL 6 (version v0.7.1rc2-10-g92bd3a3-modded) 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: common/daemon.c:45 (send_backtrace) 0x429655 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: common/daemon.c:53 (crashdump) 0x42969b 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f127918d4af 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f127918d428 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f127918f029 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f1279185bd6 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f1279185c81 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: bitcoin/tx.c:215 (push_tx) 0x436b20 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: bitcoin/tx.c:266 (bitcoin_txid) 0x4372c4 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/peer_control.c:573 (json_add_channel) 0x41c52e 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/peer_control.c:1061 (json_add_peer) 0x41cc05 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/peer_control.c:1093 (json_listpeers) 0x41d87a 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/jsonrpc.c:654 (parse_request) 0x410abb 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/jsonrpc.c:752 (read_json) 0x410c9d 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: ccan/ccan/io/io.c:59 (next_plan) 0x45658f 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: ccan/ccan/io/io.c:407 (do_plan) 0x456a4f 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: ccan/ccan/io/io.c:417 (io_ready) 0x456a7a 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: ccan/ccan/io/poll.c:445 (io_loop) 0x458123 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/io_loop_with_timers.c:24 (io_loop_with_timers) 0x40e82d 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: lightningd/lightningd.c:827 (main) 0x4122c5 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x7f127917882f 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0x403da8 2019-06-20T14:41:19.602Z lightningd(26528): backtrace: (null):0 ((null)) 0xffffffffffffffff Log dumped in crash.log.20190620144119 Ακυρώθηκε (core dumped)

crash log file

+24.109047096 lightningd(26528):jcon fd 26:IO_IN: 7b20226a736f6e72706322203a2022322e30222c20226d6574686f6422203a20226c6973747065657273222c2022696422203a20226c696768746e696e672d63 +24.109062856 lightningd(26528):jcon fd 26:IO_IN: 6c692d3236353834222c2022706172616d7322203a5b205d207d +24.120772560 lightningd(26528):BROKEN: FATAL SIGNAL 6 (version v0.7.1rc2-10-g92bd3a3-modded) +24.120792040 lightningd(26528):BROKEN: backtrace: common/daemon.c:45 (send_backtrace) 0x429655 +24.120801461 lightningd(26528):BROKEN: backtrace: common/daemon.c:53 (crashdump) 0x42969b +24.120809021 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f127918d4af +24.120815711 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f127918d428 +24.120821871 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f127918f029 +24.120827611 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f1279185bd6 +24.120833381 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f1279185c81 +24.120839232 lightningd(26528):BROKEN: backtrace: bitcoin/tx.c:215 (push_tx) 0x436b20 +24.120845272 lightningd(26528):BROKEN: backtrace: bitcoin/tx.c:266 (bitcoin_txid) 0x4372c4 +24.120852282 lightningd(26528):BROKEN: backtrace: lightningd/peer_control.c:573 (json_add_channel) 0x41c52e +24.120859492 lightningd(26528):BROKEN: backtrace: lightningd/peer_control.c:1061 (json_add_peer) 0x41cc05 +24.120866802 lightningd(26528):BROKEN: backtrace: lightningd/peer_control.c:1093 (json_listpeers) 0x41d87a +24.120873982 lightningd(26528):BROKEN: backtrace: lightningd/jsonrpc.c:654 (parse_request) 0x410abb +24.120881493 lightningd(26528):BROKEN: backtrace: lightningd/jsonrpc.c:752 (read_json) 0x410c9d +24.120887793 lightningd(26528):BROKEN: backtrace: ccan/ccan/io/io.c:59 (next_plan) 0x45658f +24.120897403 lightningd(26528):BROKEN: backtrace: ccan/ccan/io/io.c:407 (do_plan) 0x456a4f +24.120904593 lightningd(26528):BROKEN: backtrace: ccan/ccan/io/io.c:417 (io_ready) 0x456a7a +24.120911333 lightningd(26528):BROKEN: backtrace: ccan/ccan/io/poll.c:445 (io_loop) 0x458123 +24.120918114 lightningd(26528):BROKEN: backtrace: lightningd/io_loop_with_timers.c:24 (io_loop_with_timers) 0x40e82d +24.120925754 lightningd(26528):BROKEN: backtrace: lightningd/lightningd.c:827 (main) 0x4122c5 +24.120932564 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x7f127917882f +24.120938424 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0x403da8 +24.120943534 lightningd(26528):BROKEN: backtrace: (null):0 ((null)) 0xffffffffffffffff

getinfo output

{ "id" : "03a38700a1dc68bff8a4eed3b6a74c15c2ed8388dad09a0850ed12daa7de43c52e", "alias" : "VakhosDionissos", "color" : "008000", "num_peers" : 9, "num_pending_channels" : 0, "num_active_channels" : 9, "num_inactive_channels" : 0, "address" : [], "binding" : [ { "type" : "ipv6", "address" : "::", "port" : 9735 }, { "type" : "ipv4", "address" : "0.0.0.0", "port" : 9735 } ], "version" : "v0.7.1rc2-10-g92bd3a3-modded", "blockheight" : 581602, "network" : "bitcoin", "msatoshi_fees_collected" : 0, "fees_collected_msat" : "0msat" }

chek2fire avatar Jun 20 '19 14:06 chek2fire

OK, so last_tx is not extracting properly. Which is really weird, since we extracted it from the db when we loaded!

Can you run sqlite3 ~/.lightning/lightningd.sqlite3 'SELECT HEX(last_tx) FROM channels;' and past here? We'll see if any of them look funky...

I've created a branch to add some extra checks: can you try that and tell me where it crashes?

git pull https://github.com/rustyrussell/lightning/ txid-crash

Thanks!

rustyrussell avatar Jun 21 '19 00:06 rustyrussell

as i see sqlitte3 was not installed. I have install it and the sqlite3 ~/.lightning/lightningd.sqlite3 'SELECT HEX(last_tx) FROM channels;' return this

sqlite3 ~/.lightning/lightningd.sqlite3 'SELECT HEX(last_tx) FROM channels;' 0200000001A05F0FF8E2416CF66D900384E6DA2DF7B99C02996A8782E731E347134F1DBE860000000000690B1A8000D57CC520 0200000001C1E167EF8B5AA2C9465834C79111ED32BC527DED634D79FA970456C5EC5131A501000000004220CD80019163000000000000220020CFA4F698A210729912607941773CF8D9CEC84E0F94639C3F8984678472396C6E78DA3920 02000000017803CF8E9E0D1050F013E1844038736379E5700B46A0FF3ABBFE6043B5C1142401000000006D85CC8001FB5B0000000000002200209143D285184976EB779F617D38FE09FD3C9F1880F87418A05990AC0F8227A634E413DF20 020000000159350C2F4C1AAF2A73FC3C48F7D47B7D915024F21BE8A2B42B444A278CE3FCF801000000000E998D8002EC030000000000001600142BAEE4EC70C2E20550E6AF6813D1F9BA80726E01985201000000000022002031495F22A0FBB0B47978D6C7CC301132F748267C693342B924F042BA253C63D500224620 0200000001735E00D4B61DB9BC78A797E1021CC29F634BA5BE5F86132ADEEAEA4FE7A1815800000000001B1BCF8001459600000000000022002046C49BB172CF5F65D8871910727E8BDA33A9E11E01BDC50728ABE8A3FE56FDDABCC8A320 0200000001C7734C8336F5D4A04269B8B06FB13BE946B6C65A60B4BEC885CD7F6279B5A19F0100000000ADA8D1800171E7000000000000220020C80DAA058D1B44DAF76EEF8DA3D6A37054C69D328EA7DF8638A762368D1785AF74CF3720 020000000162A5E436079D3CC4081E902A1B760B33710ACD204930253E4E60A25F4E9B6617000000000053B91780012D170100000000002200209A96E899185D082C4F20B2CC521369E6BA4B01EC9755C33CC427B171E6704DDB559D2820 0200000001A61D217090280D4B4D595851108D3056C5F88278724FFCF600BC12ECF0FDF8670100000000E7089F80012D580B000000000022002040FBE6FB2A2249FB4EC8AA682240357056D857E95976BC0F9BCF8CA3B1FF4044716F6F20 0200000001FEB7B425907D1725372E663BDE0F4136F3879EF7AF22DF50B3B1F7CC17C951170100000000BC9E7880015D7A0400000000002200205896E986B5A47DFB929EB8F9E05A3DB62EB7EC8927BBF9CED841ED201537D50FA1381820

chek2fire avatar Jun 21 '19 00:06 chek2fire

Great! Ok, I've updated master witha little more diag, if you git pull now we may get more info if you can make it crash again.

Never mind, I've reproduced it!

rustyrussell avatar Jun 21 '19 03:06 rustyrussell

OK, your first 'last_tx' has no outputs! This is actually invalid, though libwally is happy to deserialize it.

We used to produce these in rare cases; I'm guessing it's your oldest channel and hasn't been updated in a long time? Unfortunately, there's not much we can do; your peer will have to broadcast its tx.

But you can fix up your node by putting a dummy tx in its place:

  1. Stop c-lightning lightning-cli stop
  2. Copy the sqlite3 db just in case: mv ~/.lightning/lightningd.sqlite3 ~/.lightning/lightningd.sqlite3.badtx
  3. sqlite3 ~/.lightning/lightningd.sqlite3.badtx .dump > sql.txt
  4. Edit sql.txt and change 0200000001A05F0FF8E2416CF66D900384E6DA2DF7B99C02996A8782E731E347134F1DBE860000000000690B1A8000D57CC520 into 0200000001A05F0FF8E2416CF66D900384E6DA2DF7B99C02996A8782E731E347134F1DBE860000000000690B1A80013C0F000000000000220020CFA4F698A210729912607941773CF8D9CEC84E0F94639C3F8984678472396C6ED57CC520.
  5. Load it back into a fresh db: sqlite3 ~/.lightning/lightningd.sqlite3 < sql.txt.
  6. Restart lightningd and (somewhat) rejoice.

SFYL :(

rustyrussell avatar Jun 21 '19 04:06 rustyrussell

BTW, you can then try closing with the peer; if successful, you won't have this problem any more. Otherwise you can try closing with force=true but your node will never forget the channel, as broadcasting the (bogus) tx will fail :(

rustyrussell avatar Jun 21 '19 04:06 rustyrussell