{"action":"created","issue":{"url":"https://api.github.com/repos/mimblewimble/grin/issues/1579","repository_url":"https://api.github.com/repos/mimblewimble/grin","labels_url":"https://api.github.com/repos/mimblewimble/grin/issues/1579/labels{/name}","comments_url":"https://api.github.com/repos/mimblewimble/grin/issues/1579/comments","events_url":"https://api.github.com/repos/mimblewimble/grin/issues/1579/events","html_url":"https://github.com/mimblewimble/grin/issues/1579","id":362885106,"node_id":"MDU6SXNzdWUzNjI4ODUxMDY=","number":1579,"title":"runtime error on SIGINT","user":{"login":"kargakis","id":3900799,"node_id":"MDQ6VXNlcjM5MDA3OTk=","avatar_url":"https://avatars3.githubusercontent.com/u/3900799?v=4","gravatar_id":"","url":"https://api.github.com/users/kargakis","html_url":"https://github.com/kargakis","followers_url":"https://api.github.com/users/kargakis/followers","following_url":"https://api.github.com/users/kargakis/following{/other_user}","gists_url":"https://api.github.com/users/kargakis/gists{/gist_id}","starred_url":"https://api.github.com/users/kargakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kargakis/subscriptions","organizations_url":"https://api.github.com/users/kargakis/orgs","repos_url":"https://api.github.com/users/kargakis/repos","events_url":"https://api.github.com/users/kargakis/events{/privacy}","received_events_url":"https://api.github.com/users/kargakis/received_events","type":"User","site_admin":false},"labels":[{"id":465821395,"node_id":"MDU6TGFiZWw0NjU4MjEzOTU=","url":"https://api.github.com/repos/mimblewimble/grin/labels/bug","name":"bug","color":"e7040f","default":true},{"id":715961908,"node_id":"MDU6TGFiZWw3MTU5NjE5MDg=","url":"https://api.github.com/repos/mimblewimble/grin/labels/good%20first%20issue","name":"good first issue","color":"96ccff","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-22T19:43:43Z","updated_at":"2018-11-25T00:41:27Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```\r\n^CSep 22 19:40:12.685 WARN Received SIGINT (Ctrl+C) or SIGTERM (kill).\r\nSep 22 19:40:12.691 WARN sync: no peers available, disabling sync\r\nSep 22 19:40:13.685 WARN Shutting down...\r\nSep 22Thread 'peer' panicked with message:\r\n\"called `Option::unwrap()` on a `None` value\"\r\nSee grin.log for further details.\r\n 19:40:13.715 ERRO \r\nthread 'peer' panicked at 'called `Option::unwrap()` on a `None` value': libcore/option.rs:345stack backtrace:\r\n   0:     0x55b899b1270c - backtrace::backtrace::trace::h97c9c167afe4715f\r\n   1:     0x55b899b124c2 - <backtrace::capture::Backtrace as core::default::Default>::default::hcc49c56acd9f8793\r\n   2:     0x55b899b12538 - backtrace::capture::Backtrace::new::hbcc3e919ce2efbce\r\n   3:     0x55b899aab79e - grin_util::logger::send_panic_to_log::{{closure}}::hac4b255e634a79ee\r\n   4:     0x55b899c206d3 - std::panicking::rust_panic_with_hook::hba05450791beb933\r\n                        at libstd/panicking.rs:479\r\n   5:     0x55b899c20279 - std::panicking::continue_panic_fmt::hd2a4220d2e2291e2\r\n                        at libstd/panicking.rs:390\r\n   6:     0x55b899c20175 - rust_begin_unwind\r\n                        at libstd/panicking.rs:325\r\n   7:     0x55b899c7b73b - core::panicking::panic_fmt::h2c383e888dce42c0\r\n                        at libcore/panicking.rs:77\r\n   8:     0x55b899c7b66a - core::panicking::panic::h14eb4ebea7b4bf80\r\n                        at libcore/panicking.rs:52\r\n   9:     0x55b8996bc47b - <grin_servers::common::adapters::NetToChainAdapter as grin_p2p::types::ChainAdapter>::headers_received::h2b4ee4729e7a0806\r\n  10:     0x55b89996a5dd - <grin_p2p::peers::Peers as grin_p2p::types::ChainAdapter>::headers_received::hce6b14f2cebc2536\r\n  11:     0x55b8999586c8 - <grin_p2p::peer::TrackingAdapter as grin_p2p::types::ChainAdapter>::headers_received::h3b320da6b6aab71a\r\n  12:     0x55b8999928e0 - <grin_p2p::protocol::Protocol as grin_p2p::conn::MessageHandler>::consume::heaca019acd21e74d\r\n  13:     0x55b899960486 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb89dd7fbe3428712\r\n  14:     0x55b899961928 - std::panicking::try::do_call::h50a754c9138776b9\r\n  15:     0x55b899c44c89 - __rust_maybe_catch_panic\r\n                        at libpanic_unwind/lib.rs:105\r\n  16:     0x55b89998b7cd - <F as alloc::boxed::FnBox<A>>::call_box::ha1c14b8365637878\r\n  17:     0x55b899c22d2a - <alloc::boxed::Box<(dyn alloc::boxed::FnBox<A, Output=R> + 'a)> as core::ops::function::FnOnce<A>>::call_once::h940efee7335c8f36\r\n                        at /checkout/src/liballoc/boxed.rs:652\r\n                         - std::sys_common::thread::start_thread::hac18b9ed82bd359d\r\n                        at libstd/sys_common/thread.rs:24\r\n  18:     0x55b899c20ca5 - std::sys::unix::thread::Thread::new::thread_start::ha15fdd35f58285a3\r\n                        at libstd/sys/unix/thread.rs:90\r\n  19:     0x7ff179187493 - start_thread\r\n  20:     0x7ff178cb2ace - __clone\r\n  21:                0x0 - <unknown>\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/mimblewimble/grin/issues/comments/441406546","html_url":"https://github.com/mimblewimble/grin/issues/1579#issuecomment-441406546","issue_url":"https://api.github.com/repos/mimblewimble/grin/issues/1579","id":441406546,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTQwNjU0Ng==","user":{"login":"jakecraige","id":3799709,"node_id":"MDQ6VXNlcjM3OTk3MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/3799709?v=4","gravatar_id":"","url":"https://api.github.com/users/jakecraige","html_url":"https://github.com/jakecraige","followers_url":"https://api.github.com/users/jakecraige/followers","following_url":"https://api.github.com/users/jakecraige/following{/other_user}","gists_url":"https://api.github.com/users/jakecraige/gists{/gist_id}","starred_url":"https://api.github.com/users/jakecraige/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakecraige/subscriptions","organizations_url":"https://api.github.com/users/jakecraige/orgs","repos_url":"https://api.github.com/users/jakecraige/repos","events_url":"https://api.github.com/users/jakecraige/events{/privacy}","received_events_url":"https://api.github.com/users/jakecraige/received_events","type":"User","site_admin":false},"created_at":"2018-11-25T00:41:27Z","updated_at":"2018-11-25T00:41:27Z","author_association":"NONE","body":"SHA/version would be helpful here. I was going to take a look at this but the code path has changed a good bit since this issue was created so it would be hard to pin down this exact occurance.\r\n\r\nHere's what I've found so far, using `0.0.0-pre.0.3.0` (released a few days after this was created), as a reference point.\r\n\r\nThe flow for the server stopping goes `server stop -> p2p peers stop -> p2p stop each connected peer`. All starting [here](https://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/servers/src/grin/server.rs#L464).\r\n\r\nThere's two unsafe paths here. First we have this where it unwraps some `RwLocks`. I'm not very familiar with the `LockResult` it returns but docs state that it could be an error if the thread that held it crashes. Since we're shutting down it seems possible this could be related.\r\n\r\nhttps://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/p2p/src/peers.rs#L482-L486\r\n\r\nSecondly we have the peer itself closing it's connection.\r\n\r\nhttps://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/p2p/src/peer.rs#L325\r\n\r\nThe connection is only initialized when the [start function](https://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/p2p/src/peer.rs#L97) is called so if we were to call stop before then, this would crash.\r\n\r\nLooking into how those are initialized. We have two places, and it turns out that there could be a race condition there. I'm not sure how long start normally takes or if there's some path where the process could have been killed between those lines finishing, but that would cause this panic.\r\n\r\nhttps://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/p2p/src/serv.rs#L221-L223\r\nhttps://github.com/mimblewimble/grin/blob/e55c3d2ec989ec633359c401c163429f04b440d2/p2p/src/serv.rs#L189-L193\r\n\r\n---\r\n\r\nNow, that's all the old code. When we look at the old code, basically all of those possibilities have been fixed.\r\n\r\nNo longer unwrapping `RwLock`s\r\n\r\nhttps://github.com/mimblewimble/grin/blob/af595fa0fc5bc7e42117b6e43e93a27305c4da4e/p2p/src/peers.rs#L435-L438\r\n\r\nAnd starting up the connection before adding it to list of peers:\r\n\r\nhttps://github.com/mimblewimble/grin/blob/af595fa0fc5bc7e42117b6e43e93a27305c4da4e/p2p/src/serv.rs#L148-L150\r\nhttps://github.com/mimblewimble/grin/blob/af595fa0fc5bc7e42117b6e43e93a27305c4da4e/p2p/src/serv.rs#L177-L178\r\n\r\nAssuming it could have been one of those conditions, it seems like this is probably fixed\r\n\r\n\r\n\r\n "}}
{"actor":{"display_login":"jakecraige"}}