Git Product home page Git Product logo

Comments (8)

Amanieu avatar Amanieu commented on July 18, 2024

I don't understand how this assert can trigger when this one in its caller didn't.

from hashbrown.

maurerdietmar avatar maurerdietmar commented on July 18, 2024

I don't understand how this assert can trigger when this one in its caller didn't.

Maybe the compiler optimize it away (or a compiler bug)?

from hashbrown.

maurerdietmar avatar maurerdietmar commented on July 18, 2024

Here is a different trace:

panicked at 'assertion failed: buckets.is_power_of_two()', /home/dietmar/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.14.3/src/raw/mod.rs:257:9

Stack:

@http://localhost:8080/frontend-76df8a485bd0132f.js:389:30

.wasm-function[console_error_panic_hook::Error::new::hd269f59fea51e7d0]@[wasm code] .wasm-function[console_error_panic_hook::hook_impl::h8fe6cbd0e14a2988]@[wasm code] .wasm-function[console_error_panic_hook::hook::hb437b654f2cbbffb]@[wasm code] .wasm-function[core::ops::function::Fn::call::h76d04d993e57483d]@[wasm code] .wasm-function[std::panicking::rust_panic_with_hook::hf80024f269e2af44]@[wasm code] .wasm-function[std::panicking::begin_panic_handler::{{closure}}::h4f7ec628c37e1d94]@[wasm code] .wasm-function[std::sys_common::backtrace::__rust_end_short_backtrace::hb367ee3be27c5afc]@[wasm code] .wasm-function[rust_begin_unwind]@[wasm code] .wasm-function[core::panicking::panic_fmt::h92300abd4d44cfd4]@[wasm code] .wasm-function[core::panicking::panic::ha477cdc2028ca479]@[wasm code] .wasm-function[hashbrown::raw::inner::TableLayout::calculate_layout_for::he8284f16a3559ecf]@[wasm code] .wasm-function[hashbrown::raw::inner::RawTableInner::allocation_info::hf96686923229b007]@[wasm code] .wasm-function[hashbrown::raw::inner::RawTableInner::free_buckets::h07029bb9325efbf3]@[wasm code] .wasm-function[hashbrown::raw::inner::RawTableInner::drop_inner_table::h3f22bf028659cee1]@[wasm code] .wasm-function[ as core::ops::drop::Drop>::drop::h39a2b2572ca1fb23]@[wasm code] .wasm-function[core::ptr::drop_in_place>::hcc6a91138ea21974]@[wasm code] .wasm-function[core::ptr::drop_in_place>::h27ebafe8c02aa260]@[wasm code] .wasm-function[core::ptr::drop_in_place>::h59f63bf27df913ff]@[wasm code] .wasm-function[core::ptr::drop_in_place::h0b000634777f063b]@[wasm code]

from hashbrown.

Amanieu avatar Amanieu commented on July 18, 2024

I'm pretty sure this isn't an issue with hashbrown, all these cases should be unreachable. Maybe you have some memory corruption somewhere? Use after free?

from hashbrown.

maurerdietmar avatar maurerdietmar commented on July 18, 2024

To debug, I added the following code:

    fn calculate_layout_for(self, buckets: usize) -> Option<(Layout, usize)> {
        if !buckets.is_power_of_two() {
            let bits = buckets.count_ones();
            panic!("BUCKETS {} {}", buckets, bits);
        }
        
        debug_assert!(buckets.is_power_of_two());

This prints:

panicked at 'BUCKETS 8 14', /home/dietmar/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.14.3/src/raw/mod.rs:259:13

So it seems that count_ones() returns total nonsense!

Does not really look like a memory corruption, because the printed value is OK.

from hashbrown.

maurerdietmar avatar maurerdietmar commented on July 18, 2024

It works if I replace the tests with:

debug_assert!(slow_is_power_of_two(buckets));

Where slow_is_power_of_two is:

fn slow_is_power_of_two(v: usize) -> bool {
    match v {
        0b1|0b10|0b100|0b1000|0b10000|0b100000|0b1000000|0b10000000 => true,
        0b100000000| 0b1000000000| 0b10000000000| 0b100000000000 | 0b1000000000000| 0b10000000000000| 0b100000000000000| 0b1000000000000000 => true,
        _ => false,
    }
}

from hashbrown.

Amanieu avatar Amanieu commented on July 18, 2024

This seems to be a bug in rustc or in the wasm runtime you are using. You should open an issue there. If possible, try to create a minimal reproducer (using #[inline(never)] to avoid constant propagation).

from hashbrown.

maurerdietmar avatar maurerdietmar commented on July 18, 2024

OK. Many thanks for your help!

from hashbrown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.