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

Segmentation fault where stack overflow expected #21072

Closed
mbauman opened this issue Mar 17, 2017 · 13 comments
Closed

Segmentation fault where stack overflow expected #21072

mbauman opened this issue Mar 17, 2017 · 13 comments
Labels
error handling Handling of exceptions by Julia or the user needs more info Clarification or a reproducible example is required system:mac Affects only macOS

Comments

@mbauman
Copy link
Member

mbauman commented Mar 17, 2017

This was a funny typo:

julia> function f()
           global f() = "hi"
           f()
       end
f (generic function with 1 method)

julia> f()
Segmentation fault: 11

Definitely an error, but probably shouldn't segfault.

@yuyichao
Copy link
Contributor

Is there a stack trace and is this mac?

@JeffBezanson
Copy link
Member

Yes, probably due to stack overflow. The new definition should not be visible inside f, so I believe this is equivalent to f() = f(). Does that also segfault?

@mbauman
Copy link
Member Author

mbauman commented Mar 17, 2017

No stack trace. This is a mac. And f() = f() correctly throws a stack overflow. With julia-debug the original example is also a stack overflow.

julia> versioninfo()
Julia Version 0.6.0-pre.alpha.155
Commit 09e7ef2 (2017-03-16 17:40 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT NO_AFFINITY NEHALEM)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, westmere)

julia> f() = f()
f (generic function with 1 method)

julia> f()
ERROR: StackOverflowError:
Stacktrace:
 [1] f() at ./REPL[2]:1 (repeats 80000 times)

@ararslan ararslan added the error handling Handling of exceptions by Julia or the user label Mar 17, 2017
@yuyichao yuyichao closed this as completed Apr 7, 2017
@StefanKarpinski
Copy link
Member

@yuyichao: can you please explain why you closed this?

@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

Dup of #17280 ..... Forgot to link...

@mbauman
Copy link
Member Author

mbauman commented Apr 7, 2017

Given that #17280 is no longer a segfault, I don't think this is a dup.

@mbauman mbauman reopened this Apr 7, 2017
@yuyichao yuyichao changed the title Segfault when redefining and calling a function within itself Segmentation fault where stack overflow expected Apr 7, 2017
@yuyichao yuyichao added the system:mac Affects only macOS label Apr 7, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

Sure we can move to this one but this is still a dup of #17280. The code that triggers the issue has been very system dependent and doesn't trigger the issue on the same system all the time either.

@mbauman
Copy link
Member Author

mbauman commented Apr 7, 2017

I can reproduce #17280 on 0.5. It's fixed on 0.6.

@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

So copying my request for more info from #17280 (comment)

If you run this in GDB, and when the segfault happens, can you set a breakpoint in cache_exception_raise and single step to after the thread_get_state call and check the following when you hit the breakpoint due to the segfault?

  1. p *ptls2 (if ptls2 is optimized out, try p *jl_all_tls_states[0])
  2. p exc_state.__faultvaddr
  3. thread apply all p $rsp
  4. thread apply all p $rbp

@yuyichao yuyichao added the needs more info Clarification or a reproducible example is required label Apr 7, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

I can reproduce #17280 on 0.5. It's fixed on 0.6.

This doesn't mean that the issue is fixed. It just means that we somehow triggers a slightly different code path (or whatever it was) that the buggy stackoverflow detection happens to be able to handle.

@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

This might also be a dup of #14284 and related to #13294 but without the info I've been requesting it's very hard to tell..................................................

@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2017

Also note that the same debugging should be done on the now incorrectly closed #17280 as well since it's most likely that the issue disappeared for unrelated reason and it's important to check if the two are actually crashing for exactly the same reason (or if the signal handler/unwinder has more than one issue)

@mbauman
Copy link
Member Author

mbauman commented Nov 3, 2017

I can no longer reproduce the original example on either 0.6.0 or master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user needs more info Clarification or a reproducible example is required system:mac Affects only macOS
Projects
None yet
Development

No branches or pull requests

5 participants