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

rusti segfaults for trivial programs #4407

Closed
wting opened this issue Jan 9, 2013 · 4 comments
Closed

rusti segfaults for trivial programs #4407

wting opened this issue Jan 9, 2013 · 4 comments
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@wting
Copy link
Contributor

wting commented Jan 9, 2013

rustc v0.6:

$ rusti
rusti>  fn foo() { for 5.times { io::println("hi"); } }
[1]    11363 segmentation fault (core dumped)  rusti
$ rusti
rusti> let x = 1;
<anon>:35:4: 35:7 warning: unused variable: `x`
<anon>:35 let x = 1;
              ^~~
[1]    11937 segmentation fault (core dumped)  rusti

I was able to reproduce this today by using ctrl+c to exit rusti. Subsequent rusti runs segfaulted regardless of the statement.

@Blei
Copy link
Contributor

Blei commented Feb 10, 2013

I spent an afternoon debugging this. It causes mysterious crashes inside dlopen() and fascinating invalid reads in valgrind, but in the end it turns out that increasing the C_STACK_SIZE in rust_sched_loop.cpp makes rusti work again (set to 100_1024_1024 here).

My theory (cobbled together using valgrind output) is, that rusti calls into the compiler, which calls into LLVMRustLoadCrate, which calls dlopen(), which in turn reads stuff into a buffer on the c stack and in the process overruns the allocated stack, wreaking general havoc.

Not sure how this can be solved elegantly, or even if my diagnosis is correct.

@thestinger
Copy link
Contributor

It seems like this problem is at least partly solved on OS X, but still exists on Linux.

@z0w0
Copy link
Contributor

z0w0 commented Mar 20, 2013

Awesome work debugging it, I've been trying to debug it for a long time. I'm not very good at debugging, haha. How can we fix this? Kind of need it fixed before 0.6.

@z0w0
Copy link
Contributor

z0w0 commented Mar 21, 2013

@brson, @nikomatsakis is there any way to allocate a larger C stack when calling LLVMRustLoadCrate at the moment (without increasing C_STACK_SIZE, which I presume is an unacceptable change)?

@z0w0 z0w0 closed this as completed Mar 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

4 participants