Skip to content

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

Description

@mstewartgallus

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions