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

Wrap const_eval_stack_frame_limit in a LockCell #56085

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/session/mod.rs
Expand Up @@ -107,7 +107,7 @@ pub struct Session {
pub type_length_limit: Once<usize>,

/// The maximum number of stackframes allowed in const eval
pub const_eval_stack_frame_limit: usize,
pub const_eval_stack_frame_limit: LockCell<usize>,

/// The metadata::creader module may inject an allocator/panic_runtime
/// dependency if it didn't already find one, and this tracks what was
Expand Down Expand Up @@ -1159,7 +1159,7 @@ pub fn build_session_(
features: Once::new(),
recursion_limit: Once::new(),
type_length_limit: Once::new(),
const_eval_stack_frame_limit: 100,
const_eval_stack_frame_limit: LockCell::new(100),
next_node_id: OneThread::new(Cell::new(NodeId::from_u32(1))),
allocator_kind: Once::new(),
injected_panic_runtime: Once::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Expand Up @@ -489,7 +489,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
debug!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);
}

if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit.get() {
err!(StackFrameLimitReached)
} else {
Ok(())
Expand Down