JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.68k stars 5.48k forks source link

Compiler hang in type inference: regression in Julia v1.11-rc3 #55809

Closed odow closed 1 month ago

odow commented 1 month ago

Reported on https://discourse.julialang.org/t/repl-hangs-at-compile/119562/4

Julia 1.11.0-rc3 installed via juliaup. Intel macOS, but discourse also reports that it happens on Windows.

oscar@Oscars-MBP /tmp % julia +1.11 --project=cosmo
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.0-rc3 (2024-08-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.11.0-rc3
Commit 616e45539db (2024-08-26 15:46 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

julia> import COSMO

julia> COSMO.Optimizer{Float64}()
^C^C^C^C^C^C^C^C^CWARNING: Force throwing a SIGINT
Internal error: during type inference of
(::Type{COSMO.Optimizer{Float64}})()
Encountered unexpected error in runtime:
InterruptException()
tmerge_types_slow at ./compiler/typelimits.jl:790
tmerge at ./compiler/typelimits.jl:704
tmerge at ./compiler/typelimits.jl:688
tmerge at ./compiler/typelimits.jl:676
tmerge at ./compiler/typelimits.jl:518
tmerge at ./compiler/typelimits.jl:478
tmerge at ./compiler/abstractlattice.jl:303
_getfield_tfunc at ./compiler/tfuncs.jl:1214
_getfield_tfunc at ./compiler/tfuncs.jl:1133 [inlined]
_getfield_tfunc at ./compiler/tfuncs.jl:1113
_getfield_tfunc at ./compiler/tfuncs.jl:1094 [inlined]
_getfield_tfunc at ./compiler/tfuncs.jl:1087 [inlined]
getfield_tfunc at ./compiler/tfuncs.jl:1053
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-5.0/build/default-macmini-x64-5-0/julialang/julia-release-1-dot-11/src/./julia.h:2157 [inlined]
do_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-5.0/build/default-macmini-x64-5-0/julialang/julia-release-1-dot-11/src/builtins.c:831
builtin_tfunction at ./compiler/tfuncs.jl:2736
abstract_call_builtin at ./compiler/abstractinterpretation.jl:1820
abstract_call_known at ./compiler/abstractinterpretation.jl:2114
abstract_call at ./compiler/abstractinterpretation.jl:2282
abstract_call at ./compiler/abstractinterpretation.jl:2275
abstract_call at ./compiler/abstractinterpretation.jl:2420
abstract_eval_call at ./compiler/abstractinterpretation.jl:2435
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2451
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2749
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:3065
typeinf_local at ./compiler/abstractinterpretation.jl:3319
typeinf_nocycle at ./compiler/abstractinterpretation.jl:3401
# ... and it goes on ...

whereas

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

julia> import COSMO

julia> COSMO.Optimizer{Float64}()
Empty COSMO - Optimizer
ViralBShah commented 1 month ago

Can you try it on the 1.11-rc4 branch? You'll need to probably build from source, but the hope was that it can be the release.

Does it happen on nightly?

odow commented 1 month ago

I'll try.

Seems like this might be fixed by https://github.com/JuliaLang/julia/pull/55757

odow commented 1 month ago

Confirmed fixed on nightly, so I'm going to declare this fixed by #55757 which has already been back-ported to rc4.

julia> import COSMO

julia> COSMO.Optimizer()
Empty COSMO - Optimizer

julia> versioninfo()
Julia Version 1.12.0-DEV.1216
Commit 00739173311 (2024-09-17 23:47 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)