Julia: Stack overflow and segfault for x' * D * x

Created on 20 Apr 2018  Â·  3Comments  Â·  Source: JuliaLang/julia


julia> using LinearAlgebra

julia> x = [1, 2, 3]
3-element Array{Int64,1}:
 1
 2
 3

julia> D = Diagonal(x)
3×3 Diagonal{Int64,Array{Int64,1}}:
  1  â‹…  â‹…
 â‹…  2  â‹…
 â‹…  â‹…  3

julia> x' * D * x
ERROR: StackOverflowError:
Stacktrace:
 [1] Type at ./boot.jl:391 [inlined]
 [2] similar at ./array.jl:262 [inlined]
 [3] similar at /Users/davidsanders/development/julia-dev/usr/share/julia/stdlib/v0.7/LinearAlgebra/src/adjtrans.jl:143 [inlined]
 [4] copymutable at ./abstractarray.jl:798 [inlined]
 [5] copy at ./abstractarray.jl:748 [inlined]
 [6] *(::Adjoint{Int64,Array{Int64,1}}, ::Diagonal{Int64,Array{Int64,1}}) at /Users/davidsanders/development/julia-dev/usr/share/julia/stdlib/v0.7/LinearAlgebra/src/diagonal.jl:484 (repeats 79998 times)

julia> x' * Diagonal(x) * x
Segmentation fault: 11
julia> versioninfo()
Julia Version 0.7.0-DEV.4909
Commit 5912b14 (2018-04-19 21:08 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin15.0.0)
  CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:
bug linear algebra mac

Most helpful comment

Copying a row vector gives a row vector again, so these just recurse infinitely:
https://github.com/JuliaLang/julia/blob/89268890342851757f1eec9e7df323ee1b20f56b/stdlib/LinearAlgebra/src/diagonal.jl#L482-L485
Also an indication that these methods are not exercised at all in our tests.

All 3 comments

The segfault I believe is platform-specific (e.g. #17109); sadly we still seem to crash on some stack overflows on mac. Linux gives the StackOverflowError each time. The stack overflow of course is due to a genuine method circularity.

But this code works without any error on 0.6.1 . Why is there a "genuine method circularity" in 0.7?

Copying a row vector gives a row vector again, so these just recurse infinitely:
https://github.com/JuliaLang/julia/blob/89268890342851757f1eec9e7df323ee1b20f56b/stdlib/LinearAlgebra/src/diagonal.jl#L482-L485
Also an indication that these methods are not exercised at all in our tests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanKarpinski picture StefanKarpinski  Â·  3Comments

tkoolen picture tkoolen  Â·  3Comments

omus picture omus  Â·  3Comments

wilburtownsend picture wilburtownsend  Â·  3Comments

TotalVerb picture TotalVerb  Â·  3Comments