Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent segfault instead of StackOverflowError when promote_rule is defined in a certain way #29657

Closed
ikirill opened this issue Oct 15, 2018 · 4 comments

Comments

@ikirill
Copy link

ikirill commented Oct 15, 2018

I don't know how to phrase it better because I don't understand what it's doing. The minimal example is reduced from the ApproxFun example below:

julia> struct A <: Number end

julia> Base.promote_rule(::Type{A}, ::Type{N}) where {N<:Number} = N

julia> promote(A(), false)
Segmentation fault: 11
julia> versioninfo()
Julia Version 1.1.0-DEV.352
Commit 4851fab9b4 (2018-10-01 13:53 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

In ApproxFun:

(v1.1) pkg> activate nightly

(nightly) pkg> st
    Status `~/Sandboxes/Julia-Misc/nightly/Project.toml`
  [28f2ccd6] ApproxFun v0.9.0+ #522d95f (https://github.com/JuliaApproximation/ApproxFun.jl.git)

julia> using ApproxFun
[ Info: Recompiling stale cache file /Users/kirill/.julia/compiled/v1.1/ApproxFun/jGqLz.ji for ApproxFun [28f2ccd6-bb30-5033-b560-165f7b14dc2f]

julia> Fun(true)
true on ApproxFun.AnyDomain()

julia> Multiplication(Fun(true))
ERROR: StackOverflowError:
Stacktrace:
 [1] promote_type at ./promotion.jl:221 [inlined]
 [2] promote_result(::Type, ::Type, ::Type{Bool}, ::Type{ApproxFun.UnsetNumber}) at ./promotion.jl:239
 ... (the last 2 lines are repeated 79998 more times)
 [159999] promote_type at ./promotion.jl:221 [inlined]

julia> Multiplication(Fun(true))
Segmentation fault: 11
@fredrikekre
Copy link
Member

Looks a lot like #29639.

@dlfivefifty
Copy link
Contributor

Hmm, I always assumed that Segfaults can happen whenever you have stack overflows, since this seems to happen often whenever there's an accidental recursive self-call.

@dlfivefifty
Copy link
Contributor

Ah, there's already an issue about recursive calls causing Segfaults: #17109

I think this issue can be closed as redundant.

@ikirill ikirill closed this as completed Oct 20, 2018
@ikirill
Copy link
Author

ikirill commented Oct 20, 2018

@dlfivefifty Usually, the correct behaviour when executing an incorrect/invalid program is to generate the specific type of error that is the correct error. Generating an incorrect error or segfaulting should definitely be a bug, even though in both cases your program doesn't work right. And a correct runtime should never segfault anyway so long as the program doesn't do anything unsafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants