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

runtime error regardless of stack size in spawn_stack #11696

Closed
ghost opened this issue Jan 21, 2014 · 6 comments
Closed

runtime error regardless of stack size in spawn_stack #11696

ghost opened this issue Jan 21, 2014 · 6 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows P-low Low priority

Comments

@ghost
Copy link

ghost commented Jan 21, 2014

This program triggers runtime error regardless of StackSize (16kB is lowest possible on pthreads):
https://gist.github.com/8533006

"fatal runtime error: assertion failed: !ptr.is_null()" + easter egg

I tried with stack sizes from 16kB up to 128MB, and all fail in same assertion.

When I replace "std::rt::thread::Thread::spawn_stack(StackSize)" with "spawn" runtime error is not triggered.

@Aatch
Copy link
Contributor

Aatch commented Jan 21, 2014

Are you replacing std::rt::thread::Thread::spawn_stack with std::rt::thread::Thread::spawn or just a call to spawn? Since Thread::spawn is implemented in terms of Thread::spawn_stack, I would expect the error to be present for both.

@ghost
Copy link
Author

ghost commented Jan 21, 2014

I replace std::rt::thread::Thread::spawn_stack(StackSize) with just a call to spawn without Thread:: prefix.

@alexcrichton
Copy link
Member

This is because we implement a "red zone" of stack at then end of a green thread's stack, and the red zone has size 20K. The thread is considered to have overflowed its stack once it enters the red zone. Obviously it's bad that the entire stack is considered the red zone.

I'm nominating this because I think this warrants discussion about what to do in this situation. The red zone allows rust_stack_exhausted to run as well as run any user-defined dtors near the end of the stack. If you specify a stack size that's less than the RED_ZONE size, then should you abort when you overflow the stack unconditionally? Should the red zone just be smaller?

Decisions, decisions...

@pnkfelix
Copy link
Member

our documentation regarding minimum stack sizes and the relationship of requested stack size versus the actual allocated stack size may need some help.

But more importantly, the bug described here does not quite match up with the diagnosis acrichto provided. Need to do a little more investigation.

Not accepting for milestone for now.

@pnkfelix
Copy link
Member

assigning P-low.

@alexcrichton
Copy link
Member

This was fixed by b02b5cd, and has tests checked in.

The original code in the gist actually failed for reasons unrelated to stack size. When attempting to block on a channel, a local task is required (and none was found), triggering the assertion.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 2, 2023
…, r=xFrednet

[`iter_without_into_iter`]: fix papercuts in suggestion and restrict linting to exported types

See rust-lang#11692 for more context.

tldr: the lint `iter_without_into_iter` has suggestions that don't compile, which imo isn't that problematic because it does have the appropriate `Applicability` that tells external tools that it shouldn't be auto-applied.
However there were some obvious "errors" in the suggestion that really should've been included in my initial PR adding the lint, which is fixed by this PR:
- `IntoIterator::into_iter` needs a `self` argument.
- `IntoIterator::Iter` associated type doesn't exist. This should've just been `Item`.

This still doesn't make it machine applicable, and the remaining things are imho quite non-trivial to implement, as I've explained in rust-lang/rust-clippy#11692 (comment).
I personally think it's fine to leave it there and let the user change the remaining errors when copy-pasting the suggestion (e.g. errors caused by lifetimes that were permitted in fn return-position but are not in associated types).
This is how many of our other lint suggestions already work.

Also, we now restrict linting to only exported types. This required moving basically all of the tests around since they were previously in the `main` function. Same for `into_iter_without_iter`. The git diff is a bit useless here...

changelog: [`iter_without_into_iter`]: fix papercuts in suggestion and restrict linting to exported types

(cc `@lopopolo,` figured I should mention you since you created the issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows P-low Low priority
Projects
None yet
Development

No branches or pull requests

3 participants