rust-lang / rust

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

Fingerprints not matching #85429

Closed myz-dev closed 3 years ago

myz-dev commented 3 years ago

Hi,

the compiler asked me to provide this bug report so I hope I can provide some useful information: I boiled the code down to:

Code

mod udp;
const INTERNAL_UDP_COMM_LOCAL_ADDR: &str = "127.0.0.1:14555";
const INTERNAL_UDP_COMM_REMOTE_ADDR: &str = "127.0.0.1:14556";
const INTERNAL_UDP_COMM_REMOTE_PORT_NO: u16 = 14556;

fn send_table() -> String {
    let mut send_buf = [0; 250];
    let mut i: u8 = 0;
    for n in 0..250 {
        send_buf[n] = i;
        i = i + 1;
    }
    let udp_sender = match udp::UdpComm::new(
        &INTERNAL_UDP_COMM_LOCAL_ADDR,
        INTERNAL_UDP_COMM_REMOTE_ADDR.to_string(),
        false,
        true,
    ) {
        Some(c) => c,
        None => {
            eprintln! {"ERROR! Could not create UdpComm object!"};
            return "ERROR! Could not create UdpComm object!".to_string();
        }
    };
    use std::net::{IpAddr, Ipv4Addr, SocketAddr};
    let remote_socket = SocketAddr::new(
        IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
        INTERNAL_UDP_COMM_REMOTE_PORT_NO,
    );

    let sent = udp_sender.sendto(&send_buf, remote_socket);
    println!("Sent out {} bytes!", sent);
    return "Send OK".to_string();
}

fn main() {
        let some_string = send_table();
        println!("{}", some_string);
}

//udp file
use std::net::UdpSocket;

pub struct UdpComm {
    _local_address: &'static str,
    _remote_address: String,
    verbose: bool,
    pub socket: UdpSocket,
}

const INVALID_IP: (u8, u8, u8, u8) = (0, 0, 0, 0);
const INVALID_PORT: u16 = 0;

impl UdpComm {
    /// creates new isntance of UdpComm
    /// can be blocking or not blocking
    /// # Arguments
    /// * 'local_addr' - pass like "127.0.0.1:6547"
    /// * 'remote_addr' - pass like "127.0.0.1:6548"
    /// * 'is_not_blocking' - determines behaviour of the socket
    /// # Examples
    /// ```rust
    /// let somestr = "127.0.0.1:34254";
    /// let my_comm = match UdpComm::new(somestr, "not used".to_string(), true) {
    ///    Some(c) => c,
    ///    None => {
    ///        eprintln! {"ERROR! Could not create UdpComm object!"};
    ///        return Ok(());
    ///    }
    /// };
    /// let mut buf = [0; 10];
    /// let (len, src) = my_comm.socket.recv_from(&mut buf)?;
    /// ```
    pub fn new(
        local_addr: &'static str,
        remote_addr: String,
        debug_output: bool,
        is_not_blocking: bool,
    ) -> Option<UdpComm> {
        match UdpSocket::bind(local_addr) {
            Ok(the_socket) => {
                Some(UdpComm {
                    _local_address: local_addr,
                    _remote_address: remote_addr,
                    verbose: debug_output,
                    socket: {
                        match the_socket.set_nonblocking(is_not_blocking) {
                        Ok(_) => println!("OK!"),
                        Err(e) => println!("Error while trying to set the socket blocking mode to {:?}. Error: {}", is_not_blocking, e),
                    }
                        the_socket
                    },
                })
            }
            Err(_) => None,
        }
    }
    pub fn sendto(&self, buf: &[u8], addr: std::net::SocketAddr) -> usize {
        use std::net::{IpAddr, Ipv4Addr};
        // check if the socket is invalid
        if addr.ip()
            == IpAddr::V4(Ipv4Addr::new(
                INVALID_IP.0,
                INVALID_IP.1,
                INVALID_IP.2,
                INVALID_IP.3,
            ))
            && addr.port() == INVALID_PORT
        {
            return 0;
        }
        let mut ret: usize = 0;

        match self.socket.send_to(buf, &addr) {
            Ok(u) => ret = u,
            Err(e) => {
                if self.verbose {
                    eprintln!("Error when sending: {:?}", e)
                };
            }
        }
        ret
    }
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (42816d61e 2021-04-24)
binary: rustc
commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
commit-date: 2021-04-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Some(Fingerprint(16583452399460452482, 11050759427754160152))`,
 right: `Some(Fingerprint(15134842177790262924, 9594111019284992043))`: found unstable fingerprints for predicates_of(core[ec89]::iter::traits::collect::IntoIterator): GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(<Self as std::iter::IntoIterator>), []), /home/myz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/collect.rs:202:1: 202:23 (#0))] }', /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/compiler/rustc_query_system/src/query/plumbing.rs:593:5
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-nightly (42816d61e 2021-04-24) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [predicates_of] computing predicates of `std::iter::IntoIterator`
#1 [typeck] type-checking `send_table`
end of query stack
error: could not compile `web_test`

To learn more, run the command again with --verbose.
Backtrace

``` thread 'rustc' panicked at 'assertion failed: `(left == right)` left: `Some(Fingerprint(16583452399460452482, 11050759427754160152))`, right: `Some(Fingerprint(15134842177790262924, 9594111019284992043))`: found unstable fingerprints for predicates_of(core[ec89]::iter::traits::collect::IntoIterator): GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(), []), /home/myz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/collect.rs:202:1: 202:23 (#0))] }', /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/compiler/rustc_query_system/src/query/plumbing.rs:593:5 stack backtrace: 0: rust_begin_unwind at /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/library/core/src/panicking.rs:92:14 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed 4: rustc_query_system::query::plumbing::incremental_verify_ich 5: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory 6: rustc_query_system::query::plumbing::get_query_impl 7: ::predicates_of 8: rustc_middle::ty::generics::GenericPredicates::instantiate_into 9: rustc_middle::ty::generics::GenericPredicates::instantiate 10: rustc_typeck::check::fn_ctxt::_impl::::instantiate_bounds 11: rustc_typeck::check::fn_ctxt::_impl::::add_required_obligations 12: rustc_typeck::check::fn_ctxt::_impl::::resolve_lang_item_path 13: rustc_typeck::check::expr::::check_expr_kind 14: rustc_typeck::check::expr::::check_expr_with_expectation 15: rustc_typeck::check::callee::::check_call 16: rustc_typeck::check::expr::::check_expr_kind 17: rustc_typeck::check::expr::::check_expr_with_expectation 18: rustc_typeck::check::_match::::demand_scrutinee_type 19: rustc_typeck::check::_match::::check_match 20: rustc_typeck::check::expr::::check_expr_kind 21: rustc_typeck::check::expr::::check_expr_with_expectation 22: rustc_typeck::check::expr::::check_expr_with_expectation 23: rustc_typeck::check::fn_ctxt::checks::::check_stmt 24: rustc_typeck::check::fn_ctxt::checks::::check_block_with_expected 25: rustc_typeck::check::expr::::check_expr_with_expectation 26: rustc_typeck::check::expr::::check_return_expr 27: rustc_typeck::check::check::check_fn 28: rustc_infer::infer::InferCtxtBuilder::enter 29: rustc_typeck::check::typeck 30: rustc_middle::dep_graph::::with_deps 31: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 32: rustc_data_structures::stack::ensure_sufficient_stack 33: rustc_query_system::query::plumbing::force_query_with_job 34: rustc_query_system::query::plumbing::get_query_impl 35: ::typeck 36: rustc_middle::ty::::par_body_owners 37: rustc_typeck::check::typeck_item_bodies 38: rustc_middle::dep_graph::::with_deps 39: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 40: rustc_data_structures::stack::ensure_sufficient_stack 41: rustc_query_system::query::plumbing::force_query_with_job 42: rustc_query_system::query::plumbing::get_query_impl 43: ::typeck_item_bodies 44: rustc_session::utils::::time 45: rustc_typeck::check_crate 46: rustc_interface::passes::analysis 47: rustc_middle::dep_graph::::with_deps 48: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 49: rustc_data_structures::stack::ensure_sufficient_stack 50: rustc_query_system::query::plumbing::force_query_with_job 51: rustc_query_system::query::plumbing::get_query_impl 52: ::analysis 53: rustc_interface::passes::QueryContext::enter 54: rustc_interface::queries::::enter 55: rustc_span::with_source_map 56: rustc_interface::interface::create_compiler_and_run 57: scoped_tls::ScopedKey::set 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.53.0-nightly (42816d61e 2021-04-24) running on x86_64-unknown-linux-gnu note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [predicates_of] computing predicates of `std::iter::IntoIterator` #1 [typeck] type-checking `send_table` #2 [typeck_item_bodies] type-checking all item bodies #3 [analysis] running analysis passes on this crate end of query stack error: could not compile `web_test` To learn more, run the command again with --verbose. ```

rkanati commented 3 years ago

check the pinned issue, #84970

advaiyalad commented 3 years ago

I think that the compiler is referring to something related to predicates_of, which has been fixed on 1.53.0-beta beta, I believe. Try upgrading to the latest nightly, you should see the error fixed.

jyn514 commented 3 years ago

I'm going to close this as a duplicate of https://github.com/rust-lang/rust/issues/84970, feel free to reopen if you can reproduce with a recent nightly. Note that your nightly is almost a month old.

myz-dev commented 3 years ago

Thank you very much. After the update it compiles just fine.