Skip to content

Commit

Permalink
ci: use miri to detect memory leak for the parser (#2037)
Browse files Browse the repository at this point in the history
We'll merge this and then eventually turn it on as a nightly check, it's
a manual run for now.
  • Loading branch information
Boshen authored Jan 15, 2024
1 parent b0f4715 commit 09c7570
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:

- name: Install Miri
run: |
rustup component add miri
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: Test with Miri
run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
run: cargo miri test -p oxc_parser
11 changes: 11 additions & 0 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ mod test {
}
}

#[test]
fn memory_leak() {
let allocator = Allocator::default();
let source_type = SourceType::default();
let sources = ["2n", ";'1234567890123456789012345678901234567890'"];
for source in sources {
let ret = Parser::new(&allocator, source, source_type).parse();
assert!(!ret.program.body.is_empty());
}
}

// Source with length u32::MAX + 1 fails to parse
#[test]
fn overlong_source() {
Expand Down

0 comments on commit 09c7570

Please sign in to comment.