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

Add diagnostic for stack allocations of 1 GB or more #119798

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

iSwapna
Copy link
Contributor

@iSwapna iSwapna commented Jan 10, 2024

Add diagnostic for stack allocations of 1 GB or more

Zulip conversation [here](Issue 83060 - Regression with large stack arrays (2-4GB))

Do I generate an ICE or issue a warning?

cc #83060

@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2024

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 10, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@iSwapna iSwapna force-pushed the issue-83060-fix branch 2 times, most recently from 9fb4f4f to 91dcd42 Compare January 13, 2024 04:20
@rust-log-analyzer

This comment has been minimized.

@iSwapna
Copy link
Contributor Author

iSwapna commented Jan 13, 2024

I have addressed all the comments, but not sure how to add the stdout file for 32 bit :
Testing stage2 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> i686-unknown-linux-gnu)
fails in CI:

failures:

  ---- [ui] tests/ui/codegen/issue-83060-large-stack-size.rs stdout ----
  diff of stderr:

  - warning: Dangerous stack allocation of size: 1 GiB exceeds most architecture limits
  -
  - warning: 1 warning emitted
  -
  -

@iSwapna iSwapna requested a review from kadiwa4 January 13, 2024 06:11
@iSwapna
Copy link
Contributor Author

iSwapna commented Jan 13, 2024

@rustbot review

@iSwapna
Copy link
Contributor Author

iSwapna commented Jan 13, 2024

I have addressed all the comments, but not sure how to add the stdout file for 32 bit : Testing stage2 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> i686-unknown-linux-gnu) fails in CI:

failures:

  ---- [ui] tests/ui/codegen/issue-83060-large-stack-size.rs stdout ----
  diff of stderr:

  - warning: Dangerous stack allocation of size: 1 GiB exceeds most architecture limits
  -
  - warning: 1 warning emitted
  -
  -

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_codegen_ssa/messages.ftl Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/mir/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/mir/mod.rs Outdated Show resolved Hide resolved
@wesleywiser wesleywiser added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 22, 2024
@Dylan-DPC
Copy link
Member

@iSwapna any updates on this? thanks

@iSwapna
Copy link
Contributor Author

iSwapna commented Feb 22, 2024

@iSwapna any updates on this? thanks

Sorry, I am taking a class @Stanford CS103, taking every bit of my time outside of work. That's towards wanting a good grounding on CS/compilers as well, to do a better job here!

There was a CI failure (fluent related) which I have not got an answer on how to address, the Zulip discussion is here: Issue 83060 - Regression with large stack arrays (2-4GB)

If I could get an answer on how to address the CI issue, I can take care of this in a couple of weeks (after impending midterm)

@Dylan-DPC
Copy link
Member

Sure, Thanks for the update. Just wanted to know if you are still working on it and have any updates. You should get a reply on zulip else you can bump it i guess

@iSwapna
Copy link
Contributor Author

iSwapna commented Feb 22, 2024

Sure, Thanks for the update. Just wanted to know if you are still working on it and have any updates. You should get a reply on zulip else you can bump it i guess

will do! Thank you for checking!

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 14, 2024
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 15, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#17 exporting to docker image format
#17 sending tarball 27.9s done
#17 DONE 33.2s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Downloaded boml v0.3.1
   Compiling boml v0.3.1
   Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
    Finished `release` profile [optimized] target(s) in 3.80s
     Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc
---
---- compiler/rustc_lint_defs/src/builtin.rs - builtin::DANGEROUS_STACK_ALLOCATION (line 720) stdout ----
warning: allocation of size: 1 GiB  exceeds most system architecture limits
 --> compiler/rustc_lint_defs/src/builtin.rs:723:9
  |
4 |     let mut x: [u8; CAP>>1] = [0; CAP>>1];
  |
  = note: `#[warn(dangerous_stack_allocation)]` on by default

warning: 1 warning emitted
warning: 1 warning emitted

Test executable failed (signal: 6 (SIGABRT) (core dumped)).
stderr:

thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
---
    compiler/rustc_lint_defs/src/builtin.rs - builtin::DANGEROUS_STACK_ALLOCATION (line 720)

test result: FAILED. 118 passed; 1 failed; 25 ignored; 0 measured; 0 filtered out; finished in 4.55s

error: doctest failed, to rerun pass `-p rustc_lint_defs --doc`
  local time: Sun Dec 15 02:08:36 UTC 2024
  network time: Sun, 15 Dec 2024 02:08:36 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@@ -0,0 +1,21 @@
// This test checks that allocating a stack size of 1GB or more results in a warning
//@build-pass
Copy link
Contributor Author

@iSwapna iSwapna Dec 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should turn the warning and test with build-fail ( since CI core dumps) or the warning needs to be an error. The failure is in doc-tests. I believe it's the latter, but want to be sure. @estebank

@iSwapna iSwapna requested a review from estebank December 15, 2024 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.