brenhinkeller / NaNStatistics.jl

Fast summary statistics, histograms, and binning – ignoring NaNs
MIT License
49 stars 3 forks source link

Stackoverflow Error #28

Closed astrobc1 closed 1 year ago

astrobc1 commented 1 year ago

The latest version (v0.6.19) doesn't compile:

julia> using NaNStatistics
[ Info: Precompiling NaNStatistics [b946abbf-3ea7-4610-9019-9858bfdeaf2d]
ERROR: LoadError: StackOverflowError:
Stacktrace:
  [1] quickselect!(A::Array{Float64, 4}, iₗ::Int64, iᵤ::Int64, k::Int64)
    @ NaNStatistics ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/quicksort.jl:74
  [2] quickselect!(A::Array{Float64, 4}, iₗ::Int64, iᵤ::Int64, k::Int64) (repeats 3960 times)
    @ NaNStatistics ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/quicksort.jl:106
  [3] _nanmedian!(A::Array{Float64, 4}, #unused#::Colon)
    @ NaNStatistics ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/nanmedian.jl:110
  [4] __nanmedian!
    @ ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/nanmedian.jl:77 [inlined]
  [5] __nanmedian
    @ ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/nanmedian.jl:20 [inlined]
  [6] #nanmedian#45
    @ ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/nanmedian.jl:17 [inlined]
  [7] nanmedian(A::Array{Float64, 4})
    @ NaNStatistics ~/.julia/packages/NaNStatistics/xpDw8/src/Sorting/nanmedian.jl:17
  [8] macro expansion
    @ ~/.julia/packages/NaNStatistics/xpDw8/src/precompile.jl:30 [inlined]
  [9] macro expansion
    @ ~/.julia/packages/SnoopPrecompile/UWvXF/src/SnoopPrecompile.jl:51 [inlined]
 [10] macro expansion
    @ ~/.julia/packages/NaNStatistics/xpDw8/src/precompile.jl:8 [inlined]
 [11] top-level scope
    @ ~/.julia/packages/SnoopPrecompile/UWvXF/src/SnoopPrecompile.jl:107
 [12] include(mod::Module, _path::String)
    @ Base ./Base.jl:419
 [13] include(x::String)
    @ NaNStatistics ~/.julia/packages/NaNStatistics/xpDw8/src/NaNStatistics.jl:1
 [14] include
    @ ./Base.jl:419 [inlined]
 [15] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1554
in expression starting at /Users/cale/.julia/packages/NaNStatistics/xpDw8/src/precompile.jl:1
in expression starting at /Users/cale/.julia/packages/NaNStatistics/xpDw8/src/NaNStatistics.jl:1
in expression starting at stdin:1
ERROR: Failed to precompile NaNStatistics [b946abbf-3ea7-4610-9019-9858bfdeaf2d] to /Users/cale/.julia/compiled/v1.8/NaNStatistics/jl_Nml0Kt.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:1707
 [3] compilecache
   @ ./loading.jl:1651 [inlined]
 [4] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1337
 [5] _require_prelocked(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1200
 [6] macro expansion
   @ ./loading.jl:1180 [inlined]
 [7] macro expansion
   @ ./lock.jl:223 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144

julia> 

Julia v1.8.0 Output of st:

Project EchelleEnv v0.1.0
Status `~/Development/EchelleEnv/Project.toml`
  [75b670ed] CurveFitParameters v0.1.0 `https://github.com/astrobc1/CurveFitParameters.jl#master`
  [39a956ec] Echelle v0.1.0 `https://github.com/astrobc1/Echelle.jl#master`
  [84cdcd4c] EchelleReduce v0.1.0 `https://github.com/astrobc1/EchelleReduce.jl#master`
  [e42e2a4f] EchelleSpectra v0.1.0 `https://github.com/astrobc1/EchelleSpectra.jl#master`
  [f749817e] EchelleSpectralModeling v0.1.0 `https://github.com/astrobc1/EchelleSpectralModeling.jl#master`
  [b2f31fbc] EchelleUtils v0.1.0 `https://github.com/astrobc1/EchelleUtils.jl#master`
  [525bcba6] FITSIO v0.17.0
  [5903a43b] Infiltrator v1.6.3
  [c4497e51] IterativeNelderMead v0.1.1 `https://github.com/astrobc1/IterativeNelderMead.jl#master`
  [b946abbf] NaNStatistics v0.6.19
  [e4faabce] PProf v2.2.2
  [f27b6e38] Polynomials v3.2.0
  [d330b81b] PyPlot v2.11.0
  [a25cea48] SpecialPolynomials v0.4.2
  [a8a75453] StatProfilerHTML v1.4.2
brenhinkeller commented 1 year ago

Oh my that's odd -- I can't seem to reproduce over here on 1.8.3, but I'll find a copy of 1.8.0 for comparison. Which OS and architecture are you on?

brenhinkeller commented 1 year ago

Hmm, doesn't reproduce on 1.8.0 for me either, but i'm testing on mac. Does this happen reproducibly in a new session?

brenhinkeller commented 1 year ago

Ah, got it to reproduce on Linux. I'm not sure the underlying problem, but I think I can release a quick workaround by dropping some functions from the snoopprecompile block

brenhinkeller commented 1 year ago

Well, curious why it didn't appear in CI but for now https://github.com/JuliaRegistries/General/pull/73137 should fix precompilation

astrobc1 commented 1 year ago

Awesome, thanks for the very quick fix! Working again with v0.6.20.