rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.47k stars 12.73k forks source link

1.40.0 ICE while reporting ICE #68813

Closed TheBlueMatt closed 4 years ago

TheBlueMatt commented 4 years ago

rustc+cargo 1.40.0 Debian testing packages report the following ICE (which does not go away after a cargo clean):

It can be reproduced by trying to build https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/tree/2020-02-ice-demo against https://github.com/TheBlueMatt/rust-lightning/tree/2020-02-rustc-ice.

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0 running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: could not compile `rust-lightning-bitcoinrpc`.

To learn more, run the command again with --verbose.
matt@cdev1:~/Documents/Projects/Bitcoin/rust-lightning-bitcoinrpc$ RUST_BACKTRACE=1 cargo build && RUST_BACKTRACE=1 ./target/debug/rust-lightning-bitcoinrpc __cookie__:f70ead21e4528ac6e74c8e182297a2b5f3041522ee55481175d4413ae552ab56@69.59.18.207:18332 `pwd`/toktest/
   Compiling rust-lightning-bitcoinrpc v0.0.1 (/home/matt/Documents/Projects/Bitcoin/rust-lightning-bitcoinrpc)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: rustc_driver::report_ice
   6: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at /usr/src/rustc-1.40.0/src/liballoc/boxed.rs:956
   7: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}
             at /usr/src/rustc-1.40.0/src/libproc_macro/bridge/client.rs:305
   8: std::panicking::rust_panic_with_hook
   9: <unknown>
  10: rust_begin_unwind
  11: core::panicking::panic_fmt
  12: core::panicking::panic
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_selection_error
  23: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_fulfillment_errors
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: rustc_typeck::collect::checked_type_of
  36: <unknown>
  37: <unknown>
  38: <unknown>
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: <unknown>
  43: <unknown>
  44: <unknown>
  45: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
  46: <unknown>
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: <unknown>
  52: <unknown>
  53: <unknown>
  54: <unknown>
  55: rustc_typeck::check_crate
  56: <unknown>
  57: <unknown>
  58: <unknown>
  59: <unknown>
  60: <unknown>
  61: <unknown>
  62: <unknown>
  63: <unknown>
  64: <unknown>
  65: <unknown>
  66: <unknown>
  67: <unknown>
  68: __rust_maybe_catch_panic
  69: <unknown>
  70: <unknown>
  71: <unknown>
  72: <unknown>
  73: start_thread
  74: __clone
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0 running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck_tables_of] processing `lightning_net_tokio::Connection::setup_outbound`
#1 [typeck_tables_of] processing `lightning_net_tokio::Connection::setup_outbound::{{closure}}#0`
#2 [typeck_tables_of] processing `main`
#3 [typeck_tables_of] processing `main::{{closure}}#0`
#4 [type_of] processing `main::{{closure}}#0`
#5 [collect_mod_item_types] collecting item types in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rust-lightning-bitcoinrpc`.

To learn more, run the command again with --verbose.
jonas-schievink commented 4 years ago

Can you try this on nightly?

pnkfelix commented 4 years ago

Once the ICEBreakers-CleanupCrew is announced (which I think will be happening very soon), we should advertise this bug on it (at least the reduction to MCVE part of it); see https://github.com/rust-lang/compiler-team/issues/207

pnkfelix commented 4 years ago

triage: P-high for initial investigation (i.e. identifying actual severity), removing nomination.

pnkfelix commented 4 years ago

@rustbot ping icebreakers-cleanup-crew

rustbot commented 4 years ago

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good "Cleanup ICE-breaking candidate". In case it's useful, here are some instructions for tackling these sorts of bugs. Maybe take a look? Thanks! <3

cc @spastorino

pnkfelix commented 4 years ago

Note that when I had a go at building rust-lightning-bitcoinrpc on my Mac laptop, it failed with this message:

error: cannot find attribute `error` in this scope
   --> src/main.rs:253:3
    |
253 | #[error("OSX creatively eats your data, using Lightning on OSX is unsafe")]
    |   ^^^^^

error: aborting due to previous error

error: could not compile `rust-lightning-bitcoinrpc`.

This is due to this line in the source crate:

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[error("OSX creatively eats your data, using Lightning on OSX is unsafe")]
struct ERR {}

So if you are on a Mac laptop, it may or may not be worth your effort to investigate this. (It is probably easy to work around, but I figure I'd let people know up front.)

TheBlueMatt commented 4 years ago

Oops, right, you'll want to just drop that line. It shouldn't have any other effect, its only there due to (at least previously, based on my super-cursory read) libstd calling regular fsync() on OSX, which historically, well, didn't fsync.

pnkfelix commented 4 years ago

I looked at this a bit more.

I see the ICE on stable and beta.

I do not see the ICE on nightly.

On nightly, I instead get the following error:

Click here to see error diagnostics ``` % cargo +nightly build warning: unnecessary parentheses around block return value --> /private/tmp/rust-lightning/lightning/src/chain/keysinterface.rs:449:3 | 449 | (Sha256::from_engine(sha).into_inner()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses | = note: `#[warn(unused_parens)]` on by default warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() --> /private/tmp/rust-lightning/lightning/src/ln/msgs.rs:741:32 | 741 | DecodeError::Io(ref e) => e.description(), | ^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() --> /private/tmp/rust-lightning/lightning/src/ln/msgs.rs:747:20 | 747 | f.write_str(self.description()) | ^^^^^^^^^^^ warning: field is never read: `logger` --> /private/tmp/rust-lightning/lightning/src/chain/chaininterface.rs:303:2 | 303 | logger: Arc, | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: field is never read: `logger` --> /private/tmp/rust-lightning/lightning/src/chain/keysinterface.rs:295:2 | 295 | logger: Arc, | ^^^^^^^^^^^^^^^^^^^ warning: variant is never constructed: `Watchtower` --> /private/tmp/rust-lightning/lightning/src/ln/channelmonitor.rs:351:2 | 351 | Watchtower { | _____^ 352 | | revocation_base_key: PublicKey, 353 | | htlc_base_key: PublicKey, 354 | | } | |_____^ warning: unused import: `lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait` --> /private/tmp/rust-lightning/lightning-net-tokio/src/lib.rs:9:5 | 9 | use lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused `std::result::Result` that must be used --> /private/tmp/rust-lightning/lightning-net-tokio/src/lib.rs:174:4 | 174 | tokio::spawn(Self::schedule_read(peer_manager, us, reader, receiver)).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> /private/tmp/rust-lightning/lightning-net-tokio/src/lib.rs:195:4 | 195 | tokio::spawn(Self::schedule_read(peer_manager, us, reader, receiver)).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled Compiling rust-lightning-bitcoinrpc v0.0.1 (/private/tmp/rust-lightning-bitcoinrpc) error[E0277]: `std::sync::MutexGuard<'_, lightning_net_tokio::Connection>` cannot be sent between threads safely --> src/main.rs:521:30 | 521 | join_handles.push(tokio::spawn(async move { | ^^^^^^^^^^^^ `std::sync::MutexGuard<'_, lightning_net_tokio::Connection>` cannot be sent between threads safely | ::: /Users/felixklock/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.11/src/task/spawn.rs:123:21 | 123 | T: Future + Send + 'static, | ---- required by this bound in `tokio::task::spawn::spawn` | = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard<'_, lightning_net_tokio::Connection>` = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9> {std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, tokio::net::tcp::stream::TcpStream, tokio::io::split::ReadHalf, tokio::sync::mpsc::bounded::Receiver<()>, std::sync::Arc>, &'r lightning::ln::peer_handler::PeerManager>>>, &'s std::sync::Arc>, lightning_net_tokio::SocketDescriptor, std::result::Result, lightning::ln::peer_handler::PeerHandleError>, std::vec::Vec, &'t0 std::sync::Mutex, std::result::Result, std::sync::PoisonError>>, lightning_net_tokio::Connection, std::sync::MutexGuard<'t3, lightning_net_tokio::Connection>, &'t4 mut std::option::Option>, std::option::Option>, std::option::Option<&'t5 mut tokio::io::split::WriteHalf>, &'t6 mut tokio::io::split::WriteHalf, &'t7 [u8], &'t8 std::vec::Vec, tokio::io::util::write_all::WriteAll<'t9, tokio::io::split::WriteHalf>, (), impl std::future::Future, tokio::task::join::JoinHandle<()>}` = note: required because it appears within the type `[static generator@DefId(75:54 ~ lightning_net_tokio[f695]::{{impl}}[0]::setup_outbound[0]::{{closure}}[0]) 0:std::sync::Arc>>>>, 1:tokio::sync::mpsc::bounded::Sender<()>, 2:secp256k1::key::PublicKey, 3:tokio::net::tcp::stream::TcpStream for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9> {std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, tokio::net::tcp::stream::TcpStream, tokio::io::split::ReadHalf, tokio::sync::mpsc::bounded::Receiver<()>, std::sync::Arc>, &'r lightning::ln::peer_handler::PeerManager>>>, &'s std::sync::Arc>, lightning_net_tokio::SocketDescriptor, std::result::Result, lightning::ln::peer_handler::PeerHandleError>, std::vec::Vec, &'t0 std::sync::Mutex, std::result::Result, std::sync::PoisonError>>, lightning_net_tokio::Connection, std::sync::MutexGuard<'t3, lightning_net_tokio::Connection>, &'t4 mut std::option::Option>, std::option::Option>, std::option::Option<&'t5 mut tokio::io::split::WriteHalf>, &'t6 mut tokio::io::split::WriteHalf, &'t7 [u8], &'t8 std::vec::Vec, tokio::io::util::write_all::WriteAll<'t9, tokio::io::split::WriteHalf>, (), impl std::future::Future, tokio::task::join::JoinHandle<()>}]` = note: required because it appears within the type `std::future::GenFuture<[static generator@DefId(75:54 ~ lightning_net_tokio[f695]::{{impl}}[0]::setup_outbound[0]::{{closure}}[0]) 0:std::sync::Arc>>>>, 1:tokio::sync::mpsc::bounded::Sender<()>, 2:secp256k1::key::PublicKey, 3:tokio::net::tcp::stream::TcpStream for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9> {std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, tokio::net::tcp::stream::TcpStream, tokio::io::split::ReadHalf, tokio::sync::mpsc::bounded::Receiver<()>, std::sync::Arc>, &'r lightning::ln::peer_handler::PeerManager>>>, &'s std::sync::Arc>, lightning_net_tokio::SocketDescriptor, std::result::Result, lightning::ln::peer_handler::PeerHandleError>, std::vec::Vec, &'t0 std::sync::Mutex, std::result::Result, std::sync::PoisonError>>, lightning_net_tokio::Connection, std::sync::MutexGuard<'t3, lightning_net_tokio::Connection>, &'t4 mut std::option::Option>, std::option::Option>, std::option::Option<&'t5 mut tokio::io::split::WriteHalf>, &'t6 mut tokio::io::split::WriteHalf, &'t7 [u8], &'t8 std::vec::Vec, tokio::io::util::write_all::WriteAll<'t9, tokio::io::split::WriteHalf>, (), impl std::future::Future, tokio::task::join::JoinHandle<()>}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `{std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, std::net::TcpStream, std::result::Result, tokio::net::tcp::stream::TcpStream, impl std::future::Future, ()}` = note: required because it appears within the type `[static generator@src/main.rs:521:54: 524:13 peer_manager:std::sync::Arc>>>>, event_notify:tokio::sync::mpsc::bounded::Sender<()>, pk:secp256k1::key::PublicKey, stream:std::net::TcpStream {std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, std::net::TcpStream, std::result::Result, tokio::net::tcp::stream::TcpStream, impl std::future::Future, ()}]` = note: required because it appears within the type `std::future::GenFuture<[static generator@src/main.rs:521:54: 524:13 peer_manager:std::sync::Arc>>>>, event_notify:tokio::sync::mpsc::bounded::Sender<()>, pk:secp256k1::key::PublicKey, stream:std::net::TcpStream {std::sync::Arc>>>>, tokio::sync::mpsc::bounded::Sender<()>, secp256k1::key::PublicKey, std::net::TcpStream, std::result::Result, tokio::net::tcp::stream::TcpStream, impl std::future::Future, ()}]>` = note: required because it appears within the type `impl std::future::Future` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. error: could not compile `rust-lightning-bitcoinrpc`. To learn more, run the command again with --verbose. ```
chrissimpkins commented 4 years ago

Possibly associated: https://github.com/rust-lang/rust/issues/66868 Possibly associated: https://github.com/rust-lang/rust/issues/68382

I am not seeing the ICE in:

Stable

rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-unknown-linux-gnu
release: 1.41.0
LLVM version: 9.0

Beta

rustc 1.42.0-beta.3 (86f329b41 2020-02-07)
binary: rustc
commit-hash: 86f329b419dbac59da59e2ac7d6e21e5eb679ec7
commit-date: 2020-02-07
host: x86_64-unknown-linux-gnu
release: 1.42.0-beta.3
LLVM version: 9.0

Nightly

rustc 1.43.0-nightly (58b834344 2020-02-05)
binary: rustc
commit-hash: 58b834344fc7b9185e7a50db1ff24e5eb07dae5e
commit-date: 2020-02-05
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Cargo bisection

searched nightlies: from nightly-2019-10-01 to nightly-2019-11-01 regressed nightly: nightly-2019-10-08 searched commits: from https://github.com/rust-lang/rust/commit/421bd77f42c2fe8a2596dbcc1580ec97fb89009f to https://github.com/rust-lang/rust/commit/f3c9cece7b6829e6fd7854a1aee6a1619a81a38c regressed commit: https://github.com/rust-lang/rust/commit/09868a56c95f7bc7b6ee3ab7611e3ca551031dbd source code: https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/tree/2020-02-ice-demo built against https://github.com/TheBlueMatt/rust-lightning/tree/2020-02-rustc-ice

Instructions

Error

COLLAPSIBLE ERROR STACKTRACE

```bash warning: field is never used: `logger` --> /home/chris/ext/rust-lightning/lightning/src/chain/chaininterface.rs:303:2 | 303 | logger: Arc, | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: field is never used: `logger` --> /home/chris/ext/rust-lightning/lightning/src/chain/keysinterface.rs:295:2 | 295 | logger: Arc, | ^^^^^^^^^^^^^^^^^^^ warning: variant is never constructed: `Watchtower` --> /home/chris/ext/rust-lightning/lightning/src/ln/channelmonitor.rs:351:2 | 351 | Watchtower { | _____^ 352 | | revocation_base_key: PublicKey, 353 | | htlc_base_key: PublicKey, 354 | | } | |_____^ Compiling futures-macro v0.3.1 Compiling tokio-util v0.2.0 Compiling pin-project v0.4.8 Compiling lightning-net-tokio v0.0.3 (/home/chris/ext/rust-lightning/lightning-net-tokio) warning: unused import: `lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait` --> /home/chris/ext/rust-lightning/lightning-net-tokio/src/lib.rs:9:5 | 9 | use lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused `std::result::Result` that must be used --> /home/chris/ext/rust-lightning/lightning-net-tokio/src/lib.rs:174:4 | 174 | tokio::spawn(Self::schedule_read(peer_manager, us, reader, receiver)).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> /home/chris/ext/rust-lightning/lightning-net-tokio/src/lib.rs:195:4 | 195 | tokio::spawn(Self::schedule_read(peer_manager, us, reader, receiver)).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled Compiling futures-util v0.3.1 Compiling h2 v0.2.1 Compiling hyper v0.13.2 error[E0658]: procedural macros cannot expand to macro definitions --> src/main.rs:326:1 | 326 | #[tokio::main] | ^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/54727 = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.40.0-nightly (09868a56c 2019-10-06) running on x86_64-unknown-linux-gnu note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. error: could not compile `rust-lightning-bitcoinrpc`. To learn more, run the command again with --verbose. 09868a56c95f7bc7b6ee3ab7611e3ca551031dbd finished with exit code Some(101). please select an action to take: tested 09868a56c95f7bc7b6ee3ab7611e3ca551031dbd, got Yes uninstalling 09868a56c95f7bc7b6ee3ab7611e3ca551031dbd searched toolchains 421bd77f42c2fe8a2596dbcc1580ec97fb89009f through f3c9cece7b6829e6fd7854a1aee6a1619a81a38c regression in 09868a56c95f7bc7b6ee3ab7611e3ca551031dbd ```

Fix

Cargo bisection

searched nightlies: from nightly-2019-11-01 to nightly-2020-01-31 fixed nightly: nightly-2019-12-08 searched commits: from https://github.com/rust-lang/rust/commit/ae1b871cca56613b1af1a5121dd24ac810ff4b89 to https://github.com/rust-lang/rust/commit/5c5c8eb864e56ce905742b8e97df5506bba6aeef fix commit: https://github.com/rust-lang/rust/commit/41601a8c95240cada94c13466a1fea02e5fe87ed source code: https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/tree/2020-02-ice-demo built against https://github.com/TheBlueMatt/rust-lightning/tree/2020-02-rustc-ice

Possibly here:

https://github.com/rust-lang/rust/blob/41601a8c95240cada94c13466a1fea02e5fe87ed/src/librustc/traits/error_reporting.rs#L2213-L2216

Instructions

jyn514 commented 4 years ago

Reduced for src/main.rs in the rust-lightning-bitcoinrpc crate (still depends on lightning):

struct RPCClient;

use lightning_net_tokio::Connection;

use tokio::sync::mpsc;
use lightning::ln::{channelmonitor, channelmanager, peer_handler};
use lightning::chain::keysinterface;

use std::sync::Arc;

struct ChannelMonitor;
impl channelmonitor::ManyChannelMonitor for ChannelMonitor {}

#[tokio::main]
async fn main() {
    let peer_manager: Arc<peer_handler::PeerManager<lightning_net_tokio::SocketDescriptor, Arc<
                channelmanager::ChannelManager<keysinterface::InMemoryChannelKeys, Arc<ChannelMonitor>>
            >>> = unimplemented!();
        let event_notify: mpsc::Sender<()> = unimplemented!();
        let stream: tokio::net::TcpStream = unimplemented!();
        let pk: secp256k1::key::PublicKey = unimplemented!();
        tokio::spawn(async move {
                Connection::setup_outbound(peer_manager, event_notify, pk, stream).await;
        });
}
jyn514 commented 4 years ago

This is happening somewhere in item-bodies checking, if I remove the body of setup_outbound with unimplemented!() the error goes away.

jyn514 commented 4 years ago

Ok, I don't have more time to spend on this, I pushed some deletions to https://github.com/jyn514/rust-lightning/tree/rust-ice-delete

jyn514 commented 4 years ago

Got it down to two files, but they have to be in different crates: https://github.com/jyn514/rust-lightning-bitcoinrpc/tree/rustc-ice

src/main.rs:

use lightning_net_tokio::Connection;

#[tokio::main]
async fn main() {
        tokio::spawn(async move {
                Connection::setup_outbound().await;
        });
}

net/src/lib.rs:

use tokio::net::TcpStream;
use tokio::io::{self, AsyncWriteExt};

use std::sync::{Arc, Mutex};

pub struct Connection {
    writer: Option<io::WriteHalf<TcpStream>>,
}
impl Connection {
    pub async fn setup_outbound() {
        let us: Arc<Mutex<Self>> = unimplemented!();
        us.lock().unwrap().writer.as_mut().unwrap().write_all(b"hi").await;
    }
}
jyn514 commented 4 years ago

A little smaller:

src/main.rs:

use lightning_net_tokio::setup_outbound;

async fn f() {
    tokio::spawn(async move {
        setup_outbound().await;
    });
}

fn main() {}

net/src/lib.rs:

use tokio::io::{WriteHalf, AsyncWriteExt, Sink};

struct Connection {
    writer: WriteHalf<Sink>,
}

pub async fn setup_outbound() {
    use std::sync::Mutex;

    let us: Mutex<Connection> = unimplemented!();
    us.lock().unwrap().writer.write_all(b"").await;
}
backtrace ``` Checking rust-lightning-bitcoinrpc v0.0.1 (/home/joshua/src/ice-repros/68813) thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:77 3: ::fmt at src/libstd/sys_common/backtrace.rs:61 4: core::fmt::write at src/libcore/fmt/mod.rs:1028 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1412 6: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:65 7: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:50 8: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:188 9: std::panicking::default_hook at src/libstd/panicking.rs:205 10: rustc_driver::report_ice 11: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:468 12: std::panicking::continue_panic_fmt at src/libstd/panicking.rs:373 13: rust_begin_unwind at src/libstd/panicking.rs:302 14: core::panicking::panic_fmt at src/libcore/panicking.rs:139 15: core::panicking::panic at src/libcore/panicking.rs:70 16: rustc_typeck::check::typeck_tables_of 17: rustc::ty::query::__query_compute::typeck_tables_of 18: rustc::ty::query::::compute 19: rustc::dep_graph::graph::DepGraph::with_task_impl 20: rustc::ty::query::plumbing::::get_query 21: rustc::ty::query::::compute 22: rustc::dep_graph::graph::DepGraph::with_task_impl 23: rustc::ty::query::plumbing::::get_query 24: rustc::traits::error_reporting::::note_obligation_cause 25: rustc::traits::error_reporting::::report_selection_error 26: rustc::traits::error_reporting::::report_fulfillment_errors 27: rustc_typeck::check::FnCtxt::resolve_generator_interiors 28: rustc::ty::context::tls::with_context::{{closure}} 29: rustc_typeck::check::typeck_tables_of 30: rustc::ty::query::::compute 31: rustc::dep_graph::graph::DepGraph::with_task_impl 32: rustc::ty::query::plumbing::::force_query 33: rustc::ty::query::plumbing::force_from_dep_node 34: rustc::dep_graph::graph::DepGraph::try_mark_previous_green 35: rustc::dep_graph::graph::DepGraph::try_mark_green 36: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read 37: rustc::ty::query::plumbing::::get_query 38: rustc_typeck::collect::checked_type_of 39: rustc_typeck::collect::type_of 40: rustc::ty::query::__query_compute::type_of 41: rustc::ty::query::::compute 42: rustc::dep_graph::graph::DepGraph::with_task_impl 43: rustc::ty::query::plumbing::::get_query 44: rustc::hir::intravisit::walk_expr 45: rustc::hir::intravisit::Visitor::visit_fn 46: rustc::hir::intravisit::walk_item 47: ::visit_item 48: rustc::hir::map::Map::visit_item_likes_in_module 49: rustc_typeck::collect::collect_mod_item_types 50: rustc::ty::query::__query_compute::collect_mod_item_types 51: rustc::ty::query::::compute 52: rustc::dep_graph::graph::DepGraph::with_task_impl 53: rustc::ty::query::plumbing::::get_query 54: rustc::ty::query::plumbing::::ensure_query 55: rustc_typeck::check_crate::{{closure}}::{{closure}} 56: rustc::util::common::time 57: rustc_typeck::check_crate 58: rustc_interface::passes::analysis 59: rustc::ty::query::__query_compute::analysis 60: rustc::dep_graph::graph::DepGraph::with_task_impl 61: rustc::ty::query::plumbing::::get_query 62: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}} 63: rustc_interface::passes::create_global_ctxt::{{closure}} 64: rustc_interface::passes::BoxedGlobalCtxt::enter 65: rustc_interface::interface::run_compiler_in_existing_thread_pool 66: std::thread::local::LocalKey::with 67: scoped_tls::ScopedKey::set 68: syntax::with_globals note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.40.0 (73528e339 2019-12-16) running on x86_64-unknown-linux-musl note: compiler flags: -C debuginfo=2 -C incremental -C target-feature=-crt-static --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck_tables_of] processing `lightning_net_tokio::setup_outbound` #1 [typeck_tables_of] processing `lightning_net_tokio::setup_outbound::{{closure}}#0` #2 [typeck_tables_of] processing `f` #3 [typeck_tables_of] processing `f::{{closure}}#0` #4 [type_of] processing `f::{{closure}}#0` #5 [collect_mod_item_types] collecting item types in top-level module #6 [analysis] running analysis passes on this crate end of query stack error: could not compile `rust-lightning-bitcoinrpc` ```
steffahn commented 4 years ago

This is a duplicate of https://github.com/rust-lang/rust/issues/67893, judging by the error message and the fact that I just confirmed 41601a8c95240cada94c13466a1fea02e5fe87ed as the fixing commit for the reduced example that I created over there. @rustbot modify labels to -E-needs-mcve.