rust-lang / rust-lang/stacker

stacker::grow Causes Invalid Memory Access

Open
#110 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
360
Forks
78
PR merge metrics
No merged PRs in 30d

Description

The stucker::grow function appears to cause invalid memory access when the input stack_size is not divisible by the page size. This issue likely originates from a miscalculation in the following code snippet:

let page_size = page_size();
let requested_pages = stack_size
    .checked_add(page_size - 1)
    .expect("unreasonably large stack requested") / page_size;
let stack_pages = std::cmp::max(1, requested_pages) + 2;
let stack_bytes = stack_pages.checked_mul(page_size);

I have tested my code extensively with various stack_size values and observed that this issue occurs specifically when the input stack_size is not divisible by the page size.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the stacker::grow function and inspect the page-count and stack-byte calculations shown in the issue. Reproduce the invalid memory access with stack_size values that are not divisible by the page size. Done means those inputs no longer cause invalid memory access and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.