<p dir="auto">EDIT: Summary:  <code class="notranslate">B = A; (t-&gt;B()).(spzeros(10))</code> constructs a sparse vector of type <code class="notranslate">Any</code>, while <code class="notranslate">(t-&gt;A()).(spzeros(10))</code> constructs correctly a sparse array of type <code class="notranslate">A</code></p>
<p dir="auto">I hope this is not a duplicate.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; struct A end
julia&gt; function test(x)
           B = A
           (t-&gt;B()).(x)
       end
julia&gt; test(zeros(1))
1-element Array{A,1}:
 A()"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">struct</span> A <span class="pl-k">end</span>
julia<span class="pl-k">&gt;</span> <span class="pl-k">function</span> <span class="pl-en">test</span>(x)
           B <span class="pl-k">=</span> A
           (t<span class="pl-k">-&gt;</span><span class="pl-c1">B</span>())<span class="pl-k">.</span>(x)
       <span class="pl-k">end</span>
julia<span class="pl-k">&gt;</span> <span class="pl-c1">test</span>(<span class="pl-c1">zeros</span>(<span class="pl-c1">1</span>))
<span class="pl-c1">1</span><span class="pl-k">-</span>element Array{A,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 <span class="pl-c1">A</span>()</pre></div>
<p dir="auto">all seems ok. However,</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; using SparseArrays
julia&gt; test(spzeros(1))
1-element SparseVector{Any,Int64} with 1 stored entry:
  [1]  =  A()"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> SparseArrays
julia<span class="pl-k">&gt;</span> <span class="pl-c1">test</span>(<span class="pl-c1">spzeros</span>(<span class="pl-c1">1</span>))
<span class="pl-c1">1</span><span class="pl-k">-</span>element SparseVector{Any,Int64} with <span class="pl-c1">1</span> stored entry<span class="pl-k">:</span>
  [<span class="pl-c1">1</span>]  <span class="pl-k">=</span>  <span class="pl-c1">A</span>()</pre></div>
<p dir="auto">So the eltype could not be infered. Note that</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; (t-&gt;A()).(spzeros(1))
1-element SparseVector{A,Int64} with 1 stored entry:
  [1]  =  A()"><pre class="notranslate">julia<span class="pl-k">&gt;</span> (t<span class="pl-k">-&gt;</span><span class="pl-c1">A</span>())<span class="pl-k">.</span>(<span class="pl-c1">spzeros</span>(<span class="pl-c1">1</span>))
<span class="pl-c1">1</span><span class="pl-k">-</span>element SparseVector{A,Int64} with <span class="pl-c1">1</span> stored entry<span class="pl-k">:</span>
  [<span class="pl-c1">1</span>]  <span class="pl-k">=</span>  <span class="pl-c1">A</span>()</pre></div>
<p dir="auto">has no problem whatsoever</p>
<p dir="auto">I could produce the following segfault with fresh Julia 1.7.0 installs on two different HPC clusters (redhat enterprise) and a regular desktop machine (ubuntu). Note that while on one machine it would already segfault for <code class="notranslate">N=5</code> on a different machine I had to set <code class="notranslate">N&gt;20</code>. So try varying this if you can't reproduce.</p>
<p dir="auto">(Julia started with multiple threads, e.g. <code class="notranslate">julia -t 8</code>)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; n = 1000;

julia&gt; N = 20;

julia&gt; Threads.@threads for i in 1:N
           A = randn(Float64, n, n); inv(A);
       end

signal (11): Segmentation fault
in expression starting at REPL[2]:1
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_64_ at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
getrf! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lapack.jl:575
#lu!#146 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:81 [inlined]
lu!##kw at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:81 [inlined]
#lu#153 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:279 [inlined]
lu at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:278 [inlined]
lu at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:278 [inlined]
inv at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:876
macro expansion at ./REPL[2]:2 [inlined]
#40#threadsfor_fun at ./threadingconstructs.jl:85
#40#threadsfor_fun at ./threadingconstructs.jl:52
unknown function (ip: 0x1554f0112d5f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877
Allocations: 4321396 (Pool: 4319432; Big: 1964); GC: 5
Segmentation fault (core dumped)"><pre class="notranslate"><code class="notranslate">julia&gt; n = 1000;

julia&gt; N = 20;

julia&gt; Threads.@threads for i in 1:N
           A = randn(Float64, n, n); inv(A);
       end

signal (11): Segmentation fault
in expression starting at REPL[2]:1
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_parallel at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
dgetrf_64_ at /cm/shared/apps/pc2/EB-SW/software/Julia/1.7.0-linux-x86_64/bin/../lib/julia/libopenblas64_.so (unknown line)
getrf! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lapack.jl:575
#lu!#146 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:81 [inlined]
lu!##kw at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:81 [inlined]
#lu#153 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:279 [inlined]
lu at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:278 [inlined]
lu at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:278 [inlined]
inv at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:876
macro expansion at ./REPL[2]:2 [inlined]
#40#threadsfor_fun at ./threadingconstructs.jl:85
#40#threadsfor_fun at ./threadingconstructs.jl:52
unknown function (ip: 0x1554f0112d5f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877
Allocations: 4321396 (Pool: 4319432; Big: 1964); GC: 5
Segmentation fault (core dumped)
</code></pre></div>
<p dir="auto">The segfault disappears when one sets <code class="notranslate">BLAS.set_num_threads(1)</code>.</p>
<p dir="auto">Likely related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1069687332" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/43301" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/43301/hovercard" href="https://github.com/JuliaLang/julia/issues/43301">#43301</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1048000796" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/43008" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/43008/hovercard" href="https://github.com/JuliaLang/julia/issues/43008">#43008</a> (caused by the same issue?). However, not really a duplicate because these issues are all about macOS and also <code class="notranslate">Float64</code> seems to be fine there.</p>
<p dir="auto">(Let me note that this is the result of me trying to create a MWE. Originally I encountered this segfault and <code class="notranslate">StackOverflowError</code>s (as in the issues linked above) as part of CI testing a private package with 1.6.4 and 1.7.0. See <a href="https://discourse.julialang.org/t/inv-causes-stack-overflow-on-julia-1-7-0-and-mac-os/72411/10" rel="nofollow">https://discourse.julialang.org/t/inv-causes-stack-overflow-on-julia-1-7-0-and-mac-os/72411/10</a>). When switching back to 1.6.3 or 1.7.0-rc1 the issues went away.)</p>