# Is this supposed to happen?

**URL:** <https://discourse.julialang.org/t/is-this-supposed-to-happen/95421>\
**Category:** General Usage\
**Created:** [March 2, 2023, 4:02am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421 "2023-03-02T04:02:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 2, 2023, 4:02am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/1 "2023-03-02T04:02:23Z")

</div>

The code bellow produces this weird message:

```julia
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:

```julia
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

```

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 3, 2023, 3:12am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/2 "2023-03-03T03:12:58Z")

</div>

Still happening: any ideas?

```julia
               _                                                                                                                
   _ _ _(_)_ | 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> 

```

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [March 3, 2023, 3:29am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/3 "2023-03-03T03:29:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [March 3, 2023, 7:43am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/4 "2023-03-03T07:43:20Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [March 3, 2023, 8:08am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/5 "2023-03-03T08:08:22Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [March 3, 2023, 8:21am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/6 "2023-03-03T08:21:48Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [March 3, 2023, 11:25am UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/7 "2023-03-03T11:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 3, 2023, 4:05pm UTC](https://discourse.julialang.org/t/is-this-supposed-to-happen/95421/8 "2023-03-03T16:05:19Z")

</div>

Thank you all, it appears it was `AbbreviatedStacktraces`.
