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 1 commit 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.

@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot assigned cjgillot and unassigned wesleywiser Sep 28, 2024
@cjgillot cjgillot 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 Sep 28, 2024
@compiler-errors
Copy link
Member

please make sure the commit history is squashed as well 😀

@rust-log-analyzer

This comment has been minimized.

@iSwapna
Copy link
Contributor Author

iSwapna commented Sep 30, 2024

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2024
compiler/rustc_codegen_ssa/messages.ftl Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/messages.ftl Outdated Show resolved Hide resolved
tests/ui/codegen/large-stack-size-issue-83060.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/messages.ftl Outdated Show resolved Hide resolved
@@ -234,6 +236,14 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let layout = start_bx.layout_of(fx.monomorphize(decl.ty));
assert!(!layout.ty.has_erasable_regions());

if layout.size.bytes() >= MIN_DANGEROUS_SIZE {
let (size_quantity, size_unit) = human_readable_bytes(layout.size.bytes());
cx.tcx().dcx().emit_warn(errors::DangerousStackAllocation {
Copy link
Member

Choose a reason for hiding this comment

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

Also if we are going to warn, perhaps should this be a lint so that people can suppress it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me figure how to add that- do you have a book pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will wait for help on the CI issue before adding more code and then having to revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can converting it to a lint be a new follow up PR? I can add an issue. This case should be a fairly rare warning ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be preferable to make this a lint in this PR. Having warnings appear that we cannot disable is not a good user experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, could you please point me to an example I can follow?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Dylan-DPC Dylan-DPC 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 Oct 3, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 4, 2024
use ilog2
Update compiler/rustc_codegen_ssa/messages.ftl
Co-authored-by: Michael Goulet <[email protected]>
Run test only on 64 bit
@cjgillot cjgillot changed the title Issue 83060 fix Add diagnostic for stack allocations of 1 GB or more Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.