Skip to content

Function evaluated on identical arguments returns different results using ApproxFunSingularities #58402

@jishnub

Description

@jishnub

The following works correctly on v1.11, but fails on v1.12-nightly and nightly.

I'm starting julia with bounds-check enabled to rule out out-of-bounds access.

julia +1.12-nightly --project --startup=no --check-bounds=yes

The issue may be replicated using the master branch of ApproxFunSingularities, but I have created a separate branch with a Manifest.toml, and I have printed out some variables to illustrate the issue. In the call exp(-x), note that C === B, but the result of domainspace(C) and domainspace(B) are different, with domainspace(C) containing garbage values.

Branch to reproduce: https://github.com/jishnub/ApproxFunSingularities.jl/tree/jishnub/exp_domainspace_error

MWE:

julia> using ApproxFunSingularities

julia> x = Fun(identity, Ray());

julia> exp(-x)
C === B = true
domainspace(B) = (1-x)^2.0 * Chebyshev()
domainspace(C) = (1+x)^6.87214963564717e-310 * (1-x)^6.39170355e-316 * Chebyshev()
ERROR: AssertionError:&& Bα
Stacktrace:
  [1] defaultConversion(A::WeightedJacobi{…}, B::JacobiWeight{…})
    @ ApproxFunSingularities ~/Dropbox/JuliaPackages/ApproxFunSingularities.jl/src/JacobiWeightOperators.jl:319
  [2] Conversion
    @ ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/banded/Conversion.jl:111 [inlined]
  [3] defaultConversion(A::WeightedJacobi{…}, B::Jacobi{…})
    @ ApproxFunSingularities ~/Dropbox/JuliaPackages/ApproxFunSingularities.jl/src/JacobiWeightOperators.jl:344
  [4] Conversion
    @ ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/banded/Conversion.jl:111 [inlined]
  [5] promotedomainspace(C::ApproxFunBase.ConversionWrapper{…}, sp::WeightedJacobi{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/banded/Conversion.jl:30
  [6] promotedomainspace(P::TimesOperator{…}, sp::JacobiWeight{…}, cursp::JacobiWeight{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/general/algebra.jl:759
  [7] promotedomainspace(P::TimesOperator{…}, sp::JacobiWeight{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/spacepromotion.jl:99
  [8] #promotedomainspace##0
    @ ./none:-1 [inlined]
  [9] iterate
    @ ./generator.jl:48 [inlined]
 [10] collect(itr::Base.Generator{Vector{…}, ApproxFunBase.var"#promotedomainspace##0#promotedomainspace##1"{…}})
    @ Base ./array.jl:790
 [11] promotedomainspace(P::PlusOperator{…}, sp::JacobiWeight{…}, cursp::JacobiWeight{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/general/algebra.jl:734
 [12] promotedomainspace(P::PlusOperator{…}, sp::JacobiWeight{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/spacepromotion.jl:99
 [13] _maybetypedmap(f::typeof(ApproxFunBase.promotedomainspace), k::JacobiWeight{…}, O::Type, ops::Vector{…})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/spacepromotion.jl:109
 [14] promotedomainspace(ops::Vector{Operator{Float64}})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/spacepromotion.jl:124
 [15] ApproxFunBase.InterlaceOperator(opsin::Vector{Operator{Float64}})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/general/InterlaceOperator.jl:220
 [16] interlace
    @ ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/general/InterlaceOperator.jl:474 [inlined]
 [17] \(A::Vector{Operator{Float64}}, b::Vector{Float64}; kwds::@Kwargs{tolerance::Float64})
    @ ApproxFunBase ~/.julia/packages/ApproxFunBase/jd32s/src/Operators/ldiv.jl:57
 [18] exp(f::Fun{JacobiWeight{Chebyshev{…}, ChebyshevInterval{…}, Float64, Int64}, Float64, Vector{Float64}})
    @ ApproxFunSingularities ~/Dropbox/JuliaPackages/ApproxFunSingularities.jl/src/ApproxFunSingularities.jl:256
 [19] exp(f::Fun{JacobiWeight{Chebyshev{Ray{}, Float64}, Ray{false, Float64}, Float64, Int64}, Float64, Vector{Float64}})
    @ ApproxFunSingularities ~/Dropbox/JuliaPackages/ApproxFunSingularities.jl/src/ApproxFunSingularities.jl:217
 [20] top-level scope
    @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> versioninfo()
Julia Version 1.12.0-beta3
Commit faca79b503a (2025-05-12 06:47 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, skylake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)

I obtain the same issue on

julia> versioninfo()
Julia Version 1.13.0-DEV.582
Commit b319a959b0a (2025-05-13 03:48 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
  WORD_SIZE: 64
  LLVM: libLLVM-19.1.7 (ORCJIT, skylake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_EDITOR = subl

The exponents in the domainspace of C are random, which seems to hint at uninitialized memory. This issue disappears if I print out B, or change the C === B check to C == B.

Metadata

Metadata

Assignees

No one assigned

    Labels

    correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingfixed on masterregressionRegression in behavior compared to a previous versionregression 1.12Regression in the 1.12 release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions