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

Problematic interaction between Stateful and map #42168

Closed
lbilli opened this issue Sep 8, 2021 · 0 comments · Fixed by #42172
Closed

Problematic interaction between Stateful and map #42168

lbilli opened this issue Sep 8, 2021 · 0 comments · Fixed by #42172
Assignees

Comments

@lbilli
Copy link
Contributor

lbilli commented Sep 8, 2021

When trying the following code:

v = split("abcd", "")
it = Iterators.Stateful(Iterators.map(identity, v))
popfirst!(it)
popfirst!(it)
collect(Iterators.take(it, 2))

in Julia 1.6.2 and 1.7.0-beta4:

signal (11): Segmentation fault
in expression starting at none:0
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:1211
jl_gc_alloc_ at /buildworker/worker/package_linux64/build/src/julia_internal.h:336 [inlined]
jl_gc_alloc at /buildworker/worker/package_linux64/build/src/gc.c:3278
jl_gc_alloc_buf at /buildworker/worker/package_linux64/build/src/julia_internal.h:370 [inlined]
[...]

whereas in Julia 1.8.0-DEV.486 a simple error (still not the right answer):

ERROR: BoundsError: attempt to access 1-element Vector{SubString{String}} at index [2]
Stacktrace:
 [1] setindex!
   @ ./array.jl:946 [inlined]
 [2] collect_to!
   @ ./array.jl:829 [inlined]
 [3] collect_to_with_first!
   @ ./array.jl:803 [inlined]
 [4] _collect(c::UnitRange{Int64}, itr::Base.Iterators.Take{Base.Iterators.Stateful{Base.Generator{Vector{SubString{String}}, typeof(identity)}, Union{Nothing, Tuple{SubString{String}, Int64}}}}, #unused#::Base.EltypeUnknown, isz::Base.HasLength)
   @ Base ./array.jl:797
 [5] collect(itr::Base.Iterators.Take{Base.Iterators.Stateful{Base.Generator{Vector{SubString{String}}, typeof(identity)}, Union{Nothing, Tuple{SubString{String}, Int64}}}})
   @ Base ./array.jl:694
 [6] top-level scope
   @ REPL[4]:1

Might be related to #35530 and #41919

@vtjnash vtjnash self-assigned this Sep 8, 2021
vtjnash added a commit that referenced this issue Sep 8, 2021
vtjnash added a commit that referenced this issue Sep 8, 2021
vtjnash added a commit that referenced this issue Sep 9, 2021
vtjnash added a commit that referenced this issue Sep 9, 2021
vtjnash added a commit that referenced this issue Sep 14, 2021
KristofferC pushed a commit that referenced this issue Sep 15, 2021
Generalization of #41919
Fixes #42168

(cherry picked from commit 68e0813)
KristofferC pushed a commit that referenced this issue Sep 15, 2021
Generalization of #41919
Fixes #42168

(cherry picked from commit 68e0813)
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Feb 22, 2022
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Mar 8, 2022
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

Successfully merging a pull request may close this issue.

2 participants