Comments (8)
I don't understand how this assert can trigger when this one in its caller didn't.
from hashbrown.
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.
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:
.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.
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.
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.
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.
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.
OK. Many thanks for your help!
from hashbrown.
Related Issues (20)
- latest/recent rev appears to break ahash/compile-time-rng usage HOT 2
- Why the identity function can be used as unlikely function? HOT 3
- `hashbrown` fails to compile as a transitive dependency HOT 2
- allocator-api2 default-feature? HOT 2
- Compiling hashbrown 0.14.2 for aarch64-unknown-linux-gnu with "target-cpu=cortex-a53" generates illegal instructions HOT 2
- Switching to GxHash? HOT 9
- Feature: increase capacity according to the actual size returned by the allocator HOT 2
- Hashbrown crash due to bad malloc HOT 1
- 0.14.3 - no method named `clear` found for struct `HashMap` in the current scope HOT 5
- Benchmark biaised due to no fence around input
- Build breaks on nightly due to use of `stdsimd` rust feature in ahash 0.8.6 HOT 2
- Was swap-remove behavior ever considered when removing entries? HOT 10
- Consider returning to 1.63.0 MSRV HOT 1
- How to calculate the size of the hashbrown::HashMap at runtime? HOT 1
- LLVM failed to use the knowledge from a never-overflow assumption HOT 13
- Library test `map::test_map::test_clone_from_memory_leaks` errors with using uninitialized data under valgrind and miri
- update to ahash 0.8.7 or after to use new stdsimd feature portable_simd HOT 1
- Insertion performance with arena allocators HOT 3
- Do not grow the raw table when lots of deletion and insertion is performed HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashbrown.