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

Unreachable reached in AtomicStructures.jl on Julia 1.8.1, but not 1.8.0 #46735

Closed
jagot opened this issue Sep 13, 2022 · 11 comments · Fixed by #46757
Closed

Unreachable reached in AtomicStructures.jl on Julia 1.8.1, but not 1.8.0 #46735

jagot opened this issue Sep 13, 2022 · 11 comments · Fixed by #46757
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch

Comments

@jagot
Copy link
Contributor

jagot commented Sep 13, 2022

https://github.com/JuliaAtoms/AtomicStructure.jl/actions/runs/3042781441/jobs/4901317463#step:6:200

Steps to reproduce:

julia> versioninfo()
Julia Version 1.8.1
Commit afb6c60d69a (2022-09-06 15:09 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 3950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 1 on 32 virtual cores

(v1.8) pkg> activate .
  Activating new project at `/export/stefanos/work/projects/test-code/test-atomic-structure`

(test-atomic-structure) pkg> add AtomicStructure
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/export/stefanos/work/projects/test-code/test-atomic-structure/Project.toml`
  [e24b7630] + AtomicStructure v0.1.2
    Updating `/export/stefanos/work/projects/test-code/test-atomic-structure/Manifest.toml`
  

(test-atomic-structure) pkg> test AtomicStructure

The same test suite works fine on 1.6 and 1.8.0. Will endeavour to produce MWE.

@jagot
Copy link
Contributor Author

jagot commented Sep 13, 2022

Smaller working example:

julia> versioninfo()
Julia Version 1.8.1
Commit afb6c60d69a (2022-09-06 15:09 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 3950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 1 on 32 virtual cores

(v1.8) pkg> activate .
  Activating new project at `/export/stefanos/work/projects/test-code/test-atomic-structure`

(test-atomic-structure) pkg> add AtomicStructure AtomicLevels CompactBases
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/export/stefanos/work/projects/test-code/test-atomic-structure/Project.toml`
  [10933b4c] + AtomicLevels v0.1.8
  [e24b7630] + AtomicStructure v0.1.2
  [2c0377a8] + CompactBases v0.3.8
  

julia> using AtomicStructure, AtomicLevels, CompactBases

julia> R = StaggeredFiniteDifferences(0.15, 0.6, 0.002, 50)
Staggered finite differences basis {Float64} on 0.0..7.7452155051783524 with 50 points with spacing varying from 0.15006749493775312 to 0.15663927831901248

julia> atom = Atom(R, csfs([c"1s", c"2s", c"2p", c"3s", c"3p", c"3d"]),
                   pc"H", verbosity=4)

TOMLs attached: unreachable-atoms.zip

@DilumAluthge
Copy link
Member

Since you're on Linux, an rr trace could be helpful. Just start Julia with julia --bug-report=rr.

@jagot
Copy link
Contributor Author

jagot commented Sep 13, 2022

Here is the crash report: https://s3.amazonaws.com/julialang-dumps/reports/2022-09-13T08-57-03-jagot.tar.zst

I had to manually create a symlink sudo ln -s /usr/lib/libcrypt.so.2 /usr/lib/libcrypt.so.1, otherwise GDB_jll and/or Python_jll would not build. Where do I report this?

@N5N3
Copy link
Member

N5N3 commented Sep 13, 2022

Reduced to

julia> using AtomicStructure: RadialOperator

julia> S = RadialOperator{T,B} where {T,B}
LazyArrays.Applied{<:Any, typeof(*), <:Tuple{var"#s128", M, var"#s127"} where {var"#s128"<:(Union{B, var"#s5"} where var"#s5"<:(QuasiArrays.SubQuasiArray{<:Any, <:Any, <:B})), var"#s127"<:(Union{var"#s7", var"#s6"} where {var"#s7"<:(QuasiArrays.QuasiAdjoint{<:Any, B}), var"#s6"<:(QuasiArrays.QuasiAdjoint{var"#s4", <:QuasiArrays.SubQuasiArray{var"#s4", var"#s8", var"#s9"}} where {var"#s4", var"#s8", var"#s9"<:B})})}} where {T, B, M<:AbstractMatrix{T}}

julia> typeintersect(S, RadialOperator)
LazyArrays.Applied{<:Any, typeof(*), <:Tuple{var"#s128", M, var"#s127"} where {B<:ContinuumArrays.Basis, M<:AbstractMatrix{T}, var"#s128"<:(QuasiArrays.SubQuasiArray{<:Any, <:Any, Union{}}), var"#s127"<:(Union{QuasiArrays.QuasiAdjoint{<:Any, B}, QuasiArrays.QuasiAdjoint{<:Any, B1}, QuasiArrays.QuasiAdjoint{var"#s4", <:QuasiArrays.SubQuasiArray{var"#s4", var"#s8", Union{}}} where {var"#s4", var"#s8"}} where B1<:ContinuumArrays.Basis)}} where T # Union{} after 9b3a2bba31fe4d18d9fa06fac6aaecc2e242d84b

@N5N3 N5N3 added bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch labels Sep 13, 2022
@KristofferC KristofferC added priority This should be addressed urgently regression Regression in behavior compared to a previous version labels Sep 13, 2022
@KristofferC
Copy link
Member

Could be worth checking if this is also due to 5d03fcd.

@vtjnash
Copy link
Member

vtjnash commented Sep 13, 2022

while working to reduce that more, I encountered this mildly interesting additional case:

julia> const RO27{B<:AtomicStructure.Basis,M<:AbstractMatrix} =
           Val{<:Tuple{
           <:Union{B, <:Val{B}},
           M,
           <:(Union{<:AtomicStructure.QuasiArrays.QuasiAdjoint{<:Any, B}, <:AtomicStructure.QuasiArrays.QuasiAdjoint{<:Any, <:Vector{<:B}}})}}
Val{<:Tuple{var"#s23", M, var"#s11"} where {var"#s23"<:(Union{B, var"#s10"} where var"#s10"<:Val{B}), var"#s11"<:(Union{var"#s9", var"#s8"} where {var"#s9"<:(QuasiArrays.QuasiAdjoint{<:Any, B}), var"#s8"<:(QuasiArrays.QuasiAdjoint{<:Any, <:Vector{<:B}})})}} where {B<:ContinuumArrays.Basis, M<:(AbstractMatrix)}

julia> typeintersect(RO27{T,S} where {T,S}, RO27)

ERROR: StackOverflowError:
Stacktrace:
 [1] typeintersect(a::Any, b::Any)
   @ Base ./reflection.jl:683
 [2] top-level scope
   @ REPL[136]:1

(it fails almost instantly, but formatting the stacktrace then takes a minute)

smaller MWEs that doesn't involve any packages:

julia> const RO36{B<:Val, M<:AbstractMatrix} =
           Tuple{
           <:Union{B, <:Val{<:B}},
           M,
           <:(Union{<:AbstractMatrix{B}, <:AbstractMatrix{<:Vector{<:B}}})}
Tuple{var"#s1", M, var"#s2"} where {B<:Val, M<:(AbstractMatrix), var"#s1"<:(Union{B, var"#s3"} where var"#s3"<:(Val{<:B})), var"#s2"<:(Union{var"#s5", var"#s6"} where {var"#s5"<:AbstractMatrix{B}, var"#s6"<:(AbstractMatrix{<:Vector{<:B}})})}

julia> typeintersect(RO36{T,S} where {T,S}, RO36)
Tuple{var"#s1", S, var"#s2"} where {S<:(AbstractMatrix), var"#s1"<:(Val{<:B} where B<:Val), var"#s2"<:(Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{Union{}}}} where B<:Val)}
# Union{}

julia> const RO37{B<:Val, M<:AbstractMatrix} =
           Tuple{
           <:Union{B, <:Val{<:B}},
           M,
           <:(Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}})}
Tuple{var"#s1", M, var"#s2"} where {B<:Val, M<:(AbstractMatrix), var"#s1"<:(Union{B, var"#s3"} where var"#s3"<:(Val{<:B})), var"#s2"<:Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}}}

julia> typeintersect(RO37{T,S} where {T,S}, RO37)
Tuple{var"#s1", S, var"#s2"} where {S<:(AbstractMatrix), var"#s1"<:(Val{<:B} where B<:Val), var"#s2"<:(Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}} where B<:Val)}
# Union{}

also ran into this additional issue too:

julia> const RO38{B<:Val, M<:AbstractMatrix} =
           Tuple{
           <:Union{B, <:Val{<:B}},
           M,
           Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}}}
Tuple{var"#s1", M, Union{AbstractMatrix{B}, AbstractMatrix{<:Vector{<:B}}}} where {B<:Val, M<:(AbstractMatrix), var"#s1"<:(Union{B, var"#s2"} where var"#s2"<:(Val{<:B}))}

julia> typeintersect(RO38{T,S} where {T,S}, RO38)
Tuple{Union{var"#s1", var"#s11"}, 
[3247358] signal (11): Segmentation fault
in expression starting at none:0
ijl_isa at /data/vtjnash/julia/src/subtype.c:2075
sig_match_simple at /data/vtjnash/julia/src/typemap.c:239 [inlined]
...
Segmentation fault

with additional MWEs:

julia> Tuple{ccall(:jl_new_structv, Any, (Any, Ptr{Cvoid}, UInt32), Union, [S, S], 2)} where S<:AbstractMatrix
Segmentation fault

julia> (ti, env) = ccall(:jl_type_intersection_with_env, Any, (Any, Any), T, AbstractMatrix); env
svec(#undef)

julia> identity(env...)
Segmentation fault

@JeffBezanson
Copy link
Member

# Union{} after 9b3a2bba31fe4d18d9fa06fac6aaecc2e242d84b

For reference, 9aabb4c on master.

@JeffBezanson
Copy link
Member

It might be possible to work around this by simplifying some type constraints a bit, e.g. in

const RadialOperator{T,B<:Basis,M<:AbstractMatrix{T}}

remove the {T} on AbstractMatrix. I haven't tried that specifically but in the past those kinds of changes tend to avoid these issues.

@vtjnash
Copy link
Member

vtjnash commented Sep 13, 2022

FWIW, it looks like they already worked around it by removing some of the extraneous <: in their type

@jagot
Copy link
Contributor Author

jagot commented Sep 14, 2022

FWIW, it looks like they already worked around it by removing some of the extraneous <: in their type

Yes, but that caused an interesting StackOverflowError on Julia < 1.8 instead: https://github.com/JuliaAtoms/AtomicStructure.jl/actions/runs/3044747652/jobs/4905539689#step:6:201

I fixed this by removing some overloads which I erroneously thought were not needed anymore, and then broke another package of mine 😱 This I have to fix today. I know that my code is rather type-heavy, because it takes ages to compile and run (for the first time). This is probably compounded by my overloading methods like Base.diff etc.

@maleadt
Copy link
Member

maleadt commented Sep 14, 2022

I had to manually create a symlink sudo ln -s /usr/lib/libcrypt.so.2 /usr/lib/libcrypt.so.1, otherwise GDB_jll and/or Python_jll would not build. Where do I report this?

Please report this on BugReporting.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants