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

SIGSEGV in a recursion loop in a custom show() method #21258

Closed
fjarri opened this issue Apr 3, 2017 · 1 comment
Closed

SIGSEGV in a recursion loop in a custom show() method #21258

fjarri opened this issue Apr 3, 2017 · 1 comment

Comments

@fjarri
Copy link
Contributor

fjarri commented Apr 3, 2017

The code:

import Base: show

immutable T
    x
end

show(io::IO, t::T) = print(io, "$t.x")

println(T(1))

Results in:

fish: 'julia t.jl' terminated by signal SIGSEGV (Address boundary error)

I discovered it when I forgot to put parentheses around t.x which, I imagine, is not an uncommon mistake. I understand, of course, that this code is bound to fail because it calls for show(::T) from show(::T), and the recursion never ends, so it is not a critical bug. Nevertheless, I would expect it to fail more gracefully, like it does if you remove .x from the print call, which just gives you

ERROR: LoadError: StackOverflowError:
<... long stack trace ...>

as expected. In a longer program it would be much easier to find the mistake from a stack trace like this than just from a SIGSEGV.

versioninfo() output:

Julia Version 0.5.1
Commit 6445c82 (2017-03-05 13:25 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin13.4.0)
CPU: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

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

2 participants