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

Infinite recursion crashes crystal #6365

Closed
felixbuenemann opened this issue Jul 11, 2018 · 2 comments
Closed

Infinite recursion crashes crystal #6365

felixbuenemann opened this issue Jul 11, 2018 · 2 comments

Comments

@felixbuenemann
Copy link
Contributor

felixbuenemann commented Jul 11, 2018

The following code crashes the crystal compiler (both master @ 8d28cbb and 0.25.1):

def foo
  foo
end

foo

Crash output:

.build/crystal run infinite_loop.cr
Invalid memory access (signal 11) at address 0x7ffedf89eff8
[0x10fb8890b] *CallStack::print_backtrace:Int32 +107
[0x10fb702a8] __crystal_sigfault_handler +72
[0x10fbc0123] sigfault_handler +35
[0x7fff59063f5a] _sigtramp +26
[0x10fb702e5] *foo:NoReturn +5
[0x10fb702e9] *foo:NoReturn +9 (524012 times)
[0x10fb61f8d] __crystal_main +1373
[0x10fbbe479] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +9
[0x10fbbe350] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +48
[0x10fb6d059] main +9

While in the above example the infinite recursion is obvious it usually happens to me if I have a method that returns a local variable with the same name as the method and I comment out the code that initializes that variable.

I'm not sure what Crystal should do best in this case, but at least giving an error message instead of crashing would be helpful.

@asterite
Copy link
Member

This is just a stack overflow, there's an open issue about this. This is a stack overflow in the compiler program, not in the compiler.

@RX14
Copy link
Contributor

RX14 commented Jul 11, 2018

You can easily notice it with the (524012 times) in the backtrace. Duplicate of #271

@RX14 RX14 closed this as completed Jul 11, 2018
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