# Bug in LinearAlgebra? How to debug a standard library

**URL:** https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079
**Category:** General Usage
**Created:** [October 12, 2025, 2:29am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079 "2025-10-12T02:29:37Z")
**Posts on this page:** 14
**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: [October 12, 2025, 2:29am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/1 "2025-10-12T02:29:37Z")

</div>

Is this known?

```julia-auto
[91133] signal 11 (2): Segmentation fault: 11
in expression starting at /Users/pkrysl/ACol.jl/runsim.jl:38
gc_alloc_map_set at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/./gc.h:360 [inlined]
gc_sweep_page at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1549 [inlined]
gc_sweep_pool_page at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1574
gc_sweep_prescan at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1640
gc_sweep_wake_all at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1661 [inlined]
gc_sweep_pool at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1806 [inlined]
_jl_gc_collect at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:3645
ijl_gc_collect at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:3893
maybe_collect at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:926 [inlined]
jl_gc_pool_alloc_inner at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1319 [inlined]
jl_gc_pool_alloc_noinline at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/gc.c:1386 [inlined]
jl_gc_alloc_ at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/./julia_internal.h:523
_new_genericmemory_ at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/src/genericmemory.c:56
GenericMemory at ./boot.jl:516 [inlined]
new_as_memoryref at ./boot.jl:535 [inlined]
Array at ./boot.jl:582 [inlined]
similar at ./array.jl:370 [inlined]
AbstractArray at ./array.jl:627
convert at ./abstractarray.jl:18 [inlined]
QRPivoted at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/qr.jl:451
Factorization at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/qr.jl:453 [inlined]
ldiv at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/LinearAlgebra.jl:643
\ at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/LinearAlgebra.jl:631 [inlined]
\ at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/generic.jl:1134

```

Mac M2 Ultra, Julia 1.11.7.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [October 12, 2025, 2:39am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/2 "2025-10-12T02:39:50Z")

</div>

Segfaults in GC are most frequently due to unrelated corruption (typically an out-of-bounds write). Try running with check bounds=yes … or better yet, use rr and go back in time to see what wrote to the corrupted address (but that’s hard and Linux-only).

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [October 12, 2025, 3:55am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/3 "2025-10-12T03:55:56Z")

</div>

> [@mbauman](#):
>
> but that’s hard

Some notes about debugging garbage collector bugs with rr: [How I debug issues with Julia GC](https://vchuravy.dev/notes/2025/07/debugging_gc/)

---

<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: [October 12, 2025, 5:07am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/4 "2025-10-12T05:07:14Z")

</div>

Bounds checking getting turned off was instructive.

```julia-auto
ERROR: LoadError: BoundsError: attempt to access 12582-element Vector{ComplexF32} at index [11995693056]
Stacktrace:
  [1] throw_boundserror(A::Vector{ComplexF32}, I::Tuple{Int64})
    @ Base ./essentials.jl:14
  [2] setindex!
    @ ./array.jl:986 [inlined]
  [3] ldiv!(A::LinearAlgebra.QRPivoted{ComplexF32, Matrix{ComplexF32}, Vector{ComplexF32}, Vector{Int64}}, B::Matrix{ComplexF32}, rcond::Float32)
    @ LinearAlgebra ~/julia-1.11.7/share/julia/stdlib/v1.11/LinearAlgebra/src/qr.jl:607
  [4] ldiv!
    @ ~/julia-1.11.7/share/julia/stdlib/v1.11/LinearAlgebra/src/qr.jl:620 [inlined]
  [5] ldiv(F::LinearAlgebra.QRPivoted{ComplexF32, Matrix{ComplexF32}, Vector{ComplexF32}, Vector{Int64}}, B::Matrix{ComplexF32})
    @ LinearAlgebra ~/julia-1.11.7/share/julia/stdlib/v1.11/LinearAlgebra/src/LinearAlgebra.jl:656
  [6] \
    @ ~/julia-1.11.7/share/julia/stdlib/v1.11/LinearAlgebra/src/LinearAlgebra.jl:631 [inlined]
  [7] \(A::Matrix{ComplexF32}, B::Matrix{ComplexF32})
    @ LinearAlgebra ~/julia-1.11.7/share/julia/stdlib/v1.11/LinearAlgebra/src/generic.jl:1134

```

But I still don’t know what happened. I want to `dev` LinearAlgebra in order to put some  
debugging prints in there, but it doesn’t seem to work. What do I do? I don’t think I had to debug  
a standard library before.  
This doesn’t seem to have done it:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/a/6a685c3a561cccb7f2dc9b8a63621741c655a32d.png)

---

<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: [October 12, 2025, 8:13am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/5 "2025-10-12T08:13:47Z")

</div>

Can you maybe share the code you’re executing that results in the error?

---

<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: [October 12, 2025, 1:22pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/6 "2025-10-12T13:22:29Z")

</div>

I’m afraid I can’t do that. Proprietary data and code. I don’t have an MWE (yet).

---

<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: [October 12, 2025, 2:13pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/7 "2025-10-12T14:13:12Z")

</div>

Does anyone know how to force Julia to pick up a modified version of the LinearAlgebra?  
I see  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f1d9b4cb383a30ae4e633723bdf3f7ac56fafd4.png)  
yet the prints are not coming. I think the code still uses the precompiled library.  
How do I change that? `precompile` does not work.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/d/5d9a61f67820dbb4bf43bc0f9cba0dbeec20a42a.png)

That is the line:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/6/860823b743310c7983b074cb0cad93225b4319ae.png)  
The pivot is garbage.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [October 12, 2025, 2:31pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/8 "2025-10-12T14:31:14Z")

</div>

> <https://github.com/JuliaLang/LinearAlgebra.jl/blob/28ee87ef523bbda55f4fd66752e67d146529f10c/README.md#using-development-versions-of-this-package>

---

<div class="post-metadata">

### Author: ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)
#### Post date: [October 12, 2025, 5:03pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/9 "2025-10-12T17:03:01Z")

</div>

The easiest approach for simple debugging is often to just monkey patch the method you’re working on. No custom sysimage or Julia build needed.

```julia-auto
julia> @eval LinearAlgebra function foo(bar, baz)
           # code copied from the real LinearAlgebra.foo
           println("what on earth happens here? x=$x, y=$y")
           # the rest of the real LinearAlgebra.foo
       end

```

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [October 13, 2025, 12:03am UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/10 "2025-10-13T00:03:06Z")

</div>

Could `Revise.track(#=standard library name=#)` work as a way to do those `@eval`s? I wouldn’t want to alter the original source files and don’t actually know the proper way to use that, I’m just curious if `LinearAlgebra` being part of the sysimage would affect Revise as it affects `dev`.

---

<div class="post-metadata">

### Author: ![bert](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bert](https://discourse.julialang.org/u/bert)
#### Post date: [October 15, 2025, 5:40pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/11 "2025-10-15T17:40:28Z")

</div>

Is there a way to view the LinearAlgebra code as it is in Julia 1.11? If you just go to the GitHub repo, the line numbers don’t match up with the error messages, so it’s changed relative to what OP was using.

---

<div class="post-metadata">

### Author: ![StevenWhitaker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevenwhitaker/32/9749_2.png) [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)
#### Post date: [October 15, 2025, 8:00pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/12 "2025-10-15T20:00:59Z")

</div>

In GitHub, you can just find the correct 1.11 release tag and browse the code that way:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/7/7796c828a1b618a642c84ce113e25c78ff2996e6.png)

Or you can launch the version of Julia you want and then use `@less` or `@edit` and it will open the correct code. (And you can look at the file path to further browse locally.)

---

<div class="post-metadata">

### Author: ![bert](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bert](https://discourse.julialang.org/u/bert)
#### Post date: [October 15, 2025, 8:34pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/13 "2025-10-15T20:34:04Z")

</div>

Oh, is this not the right place? [GitHub - JuliaLang/LinearAlgebra.jl: Julia Linear Algebra standard library](https://github.com/JuliaLang/LinearAlgebra.jl)

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [October 15, 2025, 9:52pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-how-to-debug-a-standard-library/133079/14 "2025-10-15T21:52:57Z")

</div>

In recent versions of Julia (v1.12 and up, maybe?), LinearAlgebra.jl was separated into a standalone repo. This line in the julia repo points to the relevant Git object in the LinearAlgebra.jl repo.

> <https://github.com/JuliaLang/julia/blob/3a50d6fb4b384959666c52a9105ae845c5de987a/stdlib/LinearAlgebra.version#L2-L2>

So append the hash string to, for example, `https://github.com/JuliaLang/LinearAlgebra.jl/commit/` to get a Github URL. Like this:

- [Bump actions/checkout from 4 to 5 (#1434) · JuliaLang/LinearAlgebra.jl@d568106 · GitHub](https://github.com/JuliaLang/LinearAlgebra.jl/commit/d5681068f1703644d7e5b5a6b7a9b9528d834bce)
