Is this supposed to happen?

The code bellow produces this weird message:

julia> include("C:\\Users\\pkonl\\Desktop\\weird.jl")                                                                           
Threads.nthreads() = 4                                                                                                          
BLAS.get_num_threads() = 4                                                                                                      
[ Info: mgsortho!(A)                                                                                                            
(m, n) = size(A) = (100000, 25)                                                                                                 
                                                                                                                                
SYSTEM (REPL): showing an error caused an error                                                                                 
                                                                                                                                
SYSTEM (REPL): caught exception of type MethodError while trying to handle a nested exception; giving up                        
                                                                                                                                
julia> 

MWE:

using LinearAlgebra

function coldot(A, j, i)
    m = size(A, 1)
    r = zero(eltype(A))
    @simd for k in 1:m
        r += A[k, i] * A[k, j]
    end
    return r;
end

function colnorm(A, j)
    return sqrt(coldot(A, j, j));
end

function colsubt!(A, i, j, r)
    m = size(A, 1)
    @simd for k in 1:m
        A[k, i] -= r * A[k, j]
    end
end

function normalizecol!(A, j)
    m = size(A, 1)
    r = 1.0 / colnorm(A, j)
    @simd for k in 1:m
        A[k, j] *= r
    end
end

function mgsortho!(A)
    @show m, n = size(A)
    normalizecol!(A, 1)
    for j in 2:n
        Base.Threads.@threads for i in j:n
            colsubt!(A, i, j-1, coldot(A, j-1, i))
        end
        normalizecol!(A, j)
    end
    b = 5c # error introduced on purpose
    return A
end


@show Threads.nthreads()
BLAS.set_num_threads(Threads.nthreads())
using LinearAlgebra; 
@show BLAS.get_num_threads()

m = 100000
n = 25
A = rand(m, n)
B = deepcopy(A)

A .= B
@info "mgsortho!(A)"
@time mgsortho!(A)
@show norm(A'*A - LinearAlgebra.I, Inf)

nothing

Still happening: any ideas?

               _                                                                                                                
   _       _ _(_)_     |  Documentation: https://docs.julialang.org                                                             
  (_)     | (_) (_)    |                                                                                                        
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.                                                                 
  | | | | | | |/ _` |  |                                                                                                        
  | | |_| | | | (_| |  |  Version 1.8.5 (2023-01-08)                                                                            
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release                                                               
|__/                   |                                                                                                        
                                                                                                                                
[ Info: Precompiling AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4]                                              
[ Info: Skipping precompilation since __precompile__(false). Importing AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4].                                                                                                                           
julia> using Revise; using Pkg; Pkg.activate("."); Pkg.instantiate();                                                           
  Activating project at `C:\Users\pkonl\Documents\00WIP\ThreadedWork`                                                           
                                                                                                                                
julia> include("C:\\Users\\pkonl\\Documents\\00WIP\\ThreadedWork\\integrate.jl")                                                
                                                                                                                                
SYSTEM (REPL): showing an error caused an error                                                                                 
                                                                                                                                
SYSTEM (REPL): caught exception of type MethodError while trying to handle a nested exception; giving up                        
                                                                                                                                
julia> 

I’m guessing AbbreviatedStackTraces is a culprit. What happens if you disable it in your startup config?

1 Like

Just to support @ToucheSir’s suspicion: I don’t see the same behavior, just the error that was intended (I guess).

julia> include("mwe.jl")
Threads.nthreads() = 1
BLAS.get_num_threads() = 1
[ Info: mgsortho!(A)
(m, n) = size(A) = (100000, 25)
ERROR: LoadError: UndefVarError: c not defined

I don’t have AbbreviatedStackTraces loaded, just Revise and a clean environment with the script.

I use AbbreviatedStackTraces and it seems to give me the intended error

julia> include("mwe.jl")
Threads.nthreads() = 1
BLAS.get_num_threads() = 1
[ Info: mgsortho!(A)
(m, n) = size(A) = (100000, 25)
ERROR: LoadError: UndefVarError: `c` not defined
Stacktrace:
   [1] mgsortho!(A::Matrix{Float64})
     @ Main /tmp/mwe.jl:40
   [2] ⋮ internal
     @ Unknown
   [3] include(fname::String)
     @ Base.MainInclude ./client.jl:478
Use `err` to retrieve the full stack trace.
in expression starting at /tmp/mwe.jl:57
1 Like

What’s your environment & versions? Do you have packages other than AbbreviatedStacktraces in your startup.jl? Does the error also occur if you run julia with --startup-file=no?

I had the same issue yesterday and removing AbbreviatedStacktraces solved the problem. I kept revise in the startup file.

Thank you all, it appears it was AbbreviatedStacktraces.

2 Likes