Skip to content

Commit

Permalink
fix: Add stacker to manage stack growth in the parser
Browse files Browse the repository at this point in the history
Just in case another environment has a smaller stack size than my local environment we also grow
the stack automatically. We still have the depth limit to prevent the stack from growing unbounded
  • Loading branch information
Markus Westerlind committed Sep 9, 2022
1 parent da1b031 commit 6a60a15
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions libflux/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libflux/flux-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ regex = "1.5.5"
serde = { version = "^1.0.136", features = ["derive", "rc"] }
serde_derive = "^1.0.136"
serde_json = "1.0.79"
stacker = "0.1"
structopt = "0.3.26"
thiserror = "1"
tempfile = { version = "3.3.0", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion libflux/flux-core/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,8 @@ impl<'input> Parser<'input> {
self.errs.push(format!("Program is nested too deep"));
None
} else {
Some(f(self))
// Numbers are arbitrary and were just picked from the stack docs
Some(stacker::maybe_grow(32 * 1024, 1024 * 1024, || f(self)))
};

self.depth -= 1;
Expand Down

0 comments on commit 6a60a15

Please sign in to comment.