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

Foo(Foo()) is a stackoverflow on 0.7 #73

Closed
cstjean opened this issue Aug 20, 2018 · 12 comments
Closed

Foo(Foo()) is a stackoverflow on 0.7 #73

cstjean opened this issue Aug 20, 2018 · 12 comments

Comments

@cstjean
Copy link
Contributor

cstjean commented Aug 20, 2018

julia> @with_kw struct Foo
       x=1
       y=2
       end
Foo

julia> Foo(Foo())
ERROR: StackOverflowError:
Stacktrace:
 [1] convert(::Type{Array{Union{},1}}, ::Array{Union{},1}) at /home/r2/.julia/packages/ShiftedArrays/psVhR/src/offset.jl:2
 [2] Base.Generator{Array{Union{},1},getfield(ShiftedArrays, Symbol("##35#36")){Tuple{}}}(::Function, ::Array{Union{},1}) at ./generator.jl:32 (repeats 2 times)
 ... (the last 2 lines are repeated 26665 more times)
 [53333] convert(::Type{Array{Union{},1}}, ::Array{Union{},1}) at /home/r2/.julia/packages/ShiftedArrays/psVhR/src/offset.jl:2

It worked fine on 0.6

@mauro3
Copy link
Owner

mauro3 commented Aug 20, 2018

I cannot reproduce on neither 0.7 nor 1.0:

julia> using Parameters                                                                                                                                      
                                                                                                                                                             
julia> @with_kw struct Foo
             x=1
             y=2
             end                                                                                                                                             
FFoo                                                                                                                                                         

julia> Foo(Foo())                                                                                                                                            
Foo                                                                                                                                                          
  x: Int64 1                                                                                                                                                 
  y: Int64 2                                                                                                                                                 

You have these ShiftedArrays showing up in your stack trace. What are those?

@cstjean
Copy link
Contributor Author

cstjean commented Aug 20, 2018

Good catch, it only happens with ShiftedArrays imported. Looks like type piracy.

julia> using Parameters, ShiftedArrays

julia> @with_kw struct Foo
       x=1
       y=2
       end
Foo

julia> Foo(Foo())
ERROR: StackOverflowError:
Stacktrace:
 [1] Base.Generator(::getfield(ShiftedArrays, Symbol("##35#36")){Tuple{}}, ::Array{Union{},1}) at ./generator.jl:32
 [2] convert(::Type{Array{Union{},1}}, ::Array{Union{},1}) at /home/cst-jean/.julia/packages/ShiftedArrays/psVhR/src/offset.jl:2

@cstjean
Copy link
Contributor Author

cstjean commented Aug 20, 2018

cc @piever

@piever
Copy link

piever commented Aug 20, 2018

Ups, that's bad! I'll make the package type-piracy free and tag a new release soon

@piever
Copy link

piever commented Aug 20, 2018

ShiftedArrays "only" pirates AbstractArray{<: ShiftedArray} so I'm still not sure how that creates this bug

@cstjean
Copy link
Contributor Author

cstjean commented Aug 21, 2018

That's not even type-piracy. Hmm. I'll check tomorrow which version I'm using, I can't seem to reproduce it at home.

@cstjean
Copy link
Contributor Author

cstjean commented Aug 21, 2018

At work, I'm definitely hitting it with the code above using ShiftedArrays. Maybe it's something else that's peculiar to my setup? Can anyone else reproduce? I'm on 0.7, [d96e819e] Parameters v0.9.2; [1277b4bf] ShiftedArrays v0.3.3

@piever
Copy link

piever commented Aug 21, 2018

I think I see what it is now. It's definitely unexpected and a consequence of my piracy:

julia> Array{Union{}} <: AbstractArray{<:ShiftedArray}
true

Somehow for Parameters it's important to convert a Array{Union{}} to Array and I'm pirating that method.

For the time being you can probably just comment out the incriminated method and I'll fix ShiftedArrays.

@cstjean
Copy link
Contributor Author

cstjean commented Aug 21, 2018

JuliaLang/julia#28798

@cstjean cstjean closed this as completed Aug 21, 2018
@cstjean
Copy link
Contributor Author

cstjean commented Aug 22, 2018

@piever I hit this again today with another of your packages.

julia> using ShiftedArrays, InteractBase

julia> InteractBase.textbox()
ERROR: StackOverflowError:
Stacktrace:
 [1] Base.Generator(::getfield(ShiftedArrays, Symbol("##35#36")){Tuple{}}, ::Array{Union{},1}) at ./generator.jl:32
 [2] convert(::Type{Array{Union{},1}}, ::Array{Union{},1}) at /home/cst-jean/.julia/packages/ShiftedArrays/psVhR/src/offset.jl:2
 ... (the last 2 lines are repeated 26665 more times)
 [53333] Base.Generator{Array{Union{},1},getfield(ShiftedArrays, Symbol("##35#36")){Tuple{}}}(::Function, ::Array{Union{},1}) at ./generator.jl:32 (repeats 2 times)

@cstjean
Copy link
Contributor Author

cstjean commented Aug 22, 2018

But I really do feel like your code is legit. Base should not be converting to Array{Union{}} IMHO

@piever
Copy link

piever commented Aug 22, 2018

Thanks for reporting, I too had noticed some issues with InteractBase. As a practical solution, unless there is a confirmation soonish in the other issue that it'll be fixed on the side of Base, I'll remove my convert overload.

piever pushed a commit to JuliaArrays/ShiftedArrays.jl that referenced this issue Sep 5, 2018
* dont pirate convert

* add helper functions

* docs

* drop shiftedabstractarray and generalize
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