Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashmap raw_entry crash #56158

Closed
sgodwincs opened this issue Nov 22, 2018 · 7 comments
Closed

Hashmap raw_entry crash #56158

sgodwincs opened this issue Nov 22, 2018 · 7 comments
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@sgodwincs
Copy link

sgodwincs commented Nov 22, 2018

While trying out the experimental hashmap raw entry API, I found that the following code crashes

#![feature(hash_raw_entry)]

use std::collections::HashMap;

fn main() {
    let map: HashMap<&str, &str> = HashMap::new();
    map.raw_entry().search_bucket(0, |_| false);
}

While the corresponding version using raw_entry_mut does not. I'd expect it to return None in this case since the map doesn't even have any items.

rustc 1.32.0-nightly (f1e2fa8 2018-11-20)

@sgodwincs sgodwincs changed the title Hashmap raw_entry segmentation fault Hashmap raw_entry crash Nov 22, 2018
@steveklabnik
Copy link
Member

I just double checked, and this is indeed a segfault, not a panic.

@sgodwincs
Copy link
Author

This only seems to happen when the capacity of the hashmap is 0. Using HashMap::with_capacity(1) avoids the problem.

@sfackler sfackler added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 22, 2018
@sfackler
Copy link
Member

cc #56167

@Amanieu
Copy link
Member

Amanieu commented Nov 29, 2018

cc @gankro @fintelia

@Amanieu
Copy link
Member

Amanieu commented Nov 29, 2018

RawEntry is calling search_hashed_nonempty on an empty table. RawEntryMut does the same thing, but calls reserve(1) first so it's fine.

@kpp
Copy link
Contributor

kpp commented Oct 7, 2019

There is no method ::search_bucket anymore.

@Amanieu
Copy link
Member

Amanieu commented Oct 7, 2019

The crash doesn't happen any more since the switch to hashbrown.

@Amanieu Amanieu closed this as completed Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants