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

Crash-causing bug with custom bittype #3189

Closed
malmaud opened this issue May 23, 2013 · 2 comments
Closed

Crash-causing bug with custom bittype #3189

malmaud opened this issue May 23, 2013 · 2 comments

Comments

@malmaud
Copy link
Contributor

malmaud commented May 23, 2013

Not sure exactly what's going on, or why I get a stack overflow the first time I try the illegal addition and a crash the second time. This is with Commit 81c84a9 2013-05-22 03:59:37 on OS X.

julia> using Base.Intrinsics

julia> bitstype 8 Mytype <: Unsigned

julia> mytype(x::Integer)=box(Mytype, unbox(Uint8, uint8(x)))
# methods for generic function mytype
mytype(x::Integer) at none:1

julia> mytype(1)+1
ERROR: stack overflow
 in + at promotion.jl:135 (repeats 79998 times)

julia> mytype(1)+1
fish: Job 1, 'julia' terminated by signal SIGILL (Illegal instruction)
@vtjnash
Copy link
Member

vtjnash commented May 23, 2013

You haven't defined a + operator for your bitstype, so it falls back on the generic + operations for numbers, which is to promote the two arguments and try again -- except that you haven't defined a promote_rule either, so the result of promotion is a no-op, and the result of trying again is a stack overflow.

There is no guarantee that the memory corruption has not occurred by the time the stack overflow is reported, so it may crash afterwards.

@vtjnash vtjnash closed this as completed May 23, 2013
@JeffBezanson
Copy link
Member

See also #2815

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