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

Deleting nothing from OrderedDict #87

Open
mforets opened this issue Jul 7, 2022 · 3 comments
Open

Deleting nothing from OrderedDict #87

mforets opened this issue Jul 7, 2022 · 3 comments

Comments

@mforets
Copy link

mforets commented Jul 7, 2022

Deleting nothing from OrderedDict seems to behave wildly, is it a known issue?

julia> using OrderedCollections

julia> x = OrderedDict(2 => 0.1, nothing => 0.2, 3 => 0.5)
OrderedDict{Union{Nothing, Int64}, Float64} with 3 entries:
  2       => 0.1
  nothing => 0.2
  3       => 0.5

julia> delete!(x, nothing)
OrderedDict{Union{Nothing, Int64}, Float64} with 2 entries:
  nothing => 0.1
  nothing => 0.2

julia> x
OrderedDict{Union{Nothing, Int64}, Float64} with 2 entries:
  nothing => 0.1
  nothing => 0.2

julia> x = OrderedDict(2 => 0.1, 5 => 0.4, 10 => 0.4, nothing => 0.03)
OrderedDict{Union{Nothing, Int64}, Float64} with 4 entries:
  2       => 0.1
  5       => 0.4
  10      => 0.4
  nothing => 0.03

julia> delete!(x, nothing)
OrderedDict{Union{Nothing, Int64}, Float64} with 3 entries:
  2  => 0.1
  5  => 0.4
  10 => 0.4

julia> x

signal (11): Segmentation fault
in expression starting at none:0
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:1217

For the segfault, I created an upstream report: JuliaLang/julia#45959 (comment)

@serenity4
Copy link

Could this have something to do with these lines? Maybe jl_arrayunset is called with invalid arguments or something like that. But that's just a guess, I'm not familiar with these internals.

@serenity4
Copy link

Apparently an error with out of bounds indexing according to this comment

@jakobnissen
Copy link

Not too familiar with the source code, but it looks like it happens in the rehash! function, where the code assumes that if the key is not a bitstype, it contains pointers (see the definition of the ptrs variable). This assumption is violated for union bitstypes, where the union is neither a bitstype, nor stored as a pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants