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

src/rt/rust_task.cpp has generally weird code in rust_task::new_big_stack #7022

Closed
mstewartgallus opened this issue Jun 9, 2013 · 0 comments

Comments

@mstewartgallus
Copy link
Contributor

I know that eventually the task stuff will be rewritten in Rust but for now the file src/rt/rust_task.cpp on incoming has generally weird code in the rust_task::new_big_stack method. I found out about this by using clang's static analysis capabilities (which can be used with scan-build configure; scan-build make;)

Here's some of the code which I thought was weird (it starts at https://github.com/mozilla/rust/blob/incoming/src/rt/rust_task.cpp#L614 ):

big_stack->task = this;
big_stack->next = stk->next;
if (big_stack->next)
    big_stack->next->prev = big_stack;
big_stack->prev = stk;
if (stk)
    stk->next = big_stack;

In the code, stk is dereferenced to get to nxt but is then later checked at if (stk) to see if it is null. Either the line of code big_stack->next = stk->next; should be put inside a check for nullity, or there should be an assertion that stk is not null at the top of the method, and stk should not be checked at stk->next = bit_stack;

I tried to figure out the logic here but I have no experience, and so was confused. Hopefully someone else can figure out how to correct this code.

bors added a commit that referenced this issue Jun 11, 2013
This commit fixes #7022 - I've added an additional check to ensure that
stk is not null before dereferencing it to get it's next element,
assigning NULL if it is itself NULL.
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
Fix `macro_use_import` ICE

fixes: rust-lang#7015
changelog: Fix `macro_use_import` ICE
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

1 participant