Skip to content

Segmentation fault on 0.6 & 0.7: deprecation warnings in threads #27369

Closed
@awllee

Description

@awllee

This may be quite low priority, since threads are experimental [although they work very well] and deprecations should be fixed. Nevertheless...

Deprecation warnings in threaded code appear to cause segmentation faults. This is much easier to reproduce if JULIA_NUM_THREADS=4, but the error can still occur with JULIA_NUM_THREADS=2. Replacing the deprecated method with its modern counterpart results in no segmentation faults.

using Compat.LinearAlgebra
import Compat.hasmethod
# no Compat.mul! or Compat.LinearAlgebra.mul!
if VERSION.minor == 6 mul! = A_mul_B! end

function foo1()
  v = method_exists(Base.sin, Tuple{Float64})
  # v = hasmethod(Base.sin, Tuple{Float64})
end

function foo2()
  A = [1.0 2.0; 3.0 4.0]
  b = [1.0;2.0]
  c = [0.0;0.0]
  A_mul_B!(c, A, b)
  # mul!(c, A, b)
end

function foo3()
  v = [1.0;2.0;3.0;4.0]
  log(v)
  # log.(v)
end

function bar(f::F) where F <: Function
  Threads.@threads for i in 1:4
    f()
  end
end

bar(foo1) # sometimes segfaults

bar(foo2) # often segfaults

# bar(foo3) # sometimes segfaults on v0.6.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions