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

StackOverflow in typeintersect when using Tuple type parameters #26487

Closed
daanhb opened this issue Mar 16, 2018 · 2 comments
Closed

StackOverflow in typeintersect when using Tuple type parameters #26487

daanhb opened this issue Mar 16, 2018 · 2 comments
Assignees
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior

Comments

@daanhb
Copy link
Contributor

daanhb commented Mar 16, 2018

I'm making a new issue for an older issue (#22239) that was partially fixed. The problem is a StackOverflow error in the following minimal working example:

bar(::Type{Val{Tuple{Tuple{T},T}}}, ::Val{T}) where {T} = 1
bar(::Type{Val{Tuple{T,Tuple{T}}}}, ::Val{T}) where {T} = 2

The output using the current nightly build is:

ERROR: LoadError: StackOverflowError:
Stacktrace:
 [1] top-level scope
 [2] include at ./boot.jl:306 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1072
 [4] include(::Module, ::String) at ./sysimg.jl:29
 [5] exec_options(::Base.JLOptions) at ./client.jl:327
 [6] _start() at ./client.jl:455
in expression starting at /tmp/mwe.jl:2

As @martinholters pointed out in #22239, the error results from typeintersect as follows:

julia> typeintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T)
ERROR: StackOverflowError:
Stacktrace:
 [1] typeintersect(::Any, ::Any) at ./reflection.jl:469
 [2] top-level scope

Above examples were tested today on master:

julia> versioninfo()
Julia Version 0.7.0-DEV.4594
Commit 29a1719f95 (2018-03-15 22:41 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
Environment:

The examples do also lead to similar errors on 0.6.2.

@daanhb
Copy link
Contributor Author

daanhb commented Jun 18, 2018

This stack overflow in typeintersect is still an issue on 0.7.0-alpha.0:

julia> typeintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T)
ERROR: StackOverflowError:
Stacktrace:
 [1] typeintersect(::Any, ::Any) at ./reflection.jl:475
 [2] top-level scope
julia> versioninfo()
Julia Version 0.7.0-alpha.0
Commit 22590d529d (2018-05-31 00:07 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

The original MWE above also still triggers the stack overflow on v0.7.0-alpha.0, with error messages very similar to those of the nightly builds in March.

@JeffBezanson JeffBezanson added the kind:bug Indicates an unexpected problem or unintended behavior label Sep 27, 2018
@JeffBezanson JeffBezanson self-assigned this Feb 15, 2019
@daanhb
Copy link
Contributor Author

daanhb commented Jun 14, 2019

I wanted to close an old issue today, but unfortunately it persists even in the 1.2 release candidate, hence a friendly bump:

julia> typeintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T)
ERROR: StackOverflowError:
Stacktrace:
 [1] typeintersect(::Any, ::Any) at ./reflection.jl:560
 [2] top-level scope at REPL[1]:1

julia> versioninfo()
Julia Version 1.2.0-rc1.0
Commit 7097799cf1 (2019-05-30 02:22 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)

I originally came to this minimal working example when working on code to convert between tuples and static arrays, in nested cases. I wanted an efficient way to identify ((1,2),3) with [1,2,3] and to convert between the two, since the former would naturally arise in constructions of domains using set operations (in DomainSets.jl), but the latter is a more efficient (and user-friendly) way of representing points in the domain. That explains my interest in nested tuples in the example.

N5N3 added a commit to N5N3/julia that referenced this issue Jan 11, 2023
close JuliaLang#26487.
This should be valid as we never set `X<:Y<:X` (assuming `Y` is outer var).
N5N3 added a commit to N5N3/julia that referenced this issue Jan 11, 2023
close JuliaLang#26487.
This should be valid as we never set `X<:Y<:X` (assuming `Y` is outer var).
N5N3 added a commit to N5N3/julia that referenced this issue Jan 11, 2023
close JuliaLang#26487.
This should be valid as we never set `X<:Y<:X` (assuming `Y` is the outer var).
N5N3 added a commit to N5N3/julia that referenced this issue Jan 11, 2023
close JuliaLang#26487.
This should be valid as we never set `X<:Y<:X` (assuming `Y` is the outer var).
@N5N3 N5N3 closed this as completed in 3933f90 Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants