#5367·boa

Memory allocation failure when processing file

Author: qarminCreated May 15, 2026Updated Sep 18, 2026

File content(at the bottom should be attached raw, not formatted file - github removes some non-printable characters, so copying from here may not work):

"o".repeat(1<<30)

Reproducer

I tried this code:

rust
use std::env::args;
use std::fs;
use std::path::Path;

use boa_engine::{Context, Source};
// use dicom_core::header::Header;
fn main() {
    let path = std::env::args().nth(1).unwrap();
    check_file(&path);
}

fn check_file(path: &str) {
    let Ok(file_content) = fs::read(path) else {
        return;
    };
    println!("Checking file: {path}");
    let mut context = Context::default();

    let _result = context.eval(Source::from_bytes(&file_content));
}

command

timeout -v 40 boa_normal TEST___FILE.js

App was compiled with nightly rust compiler to be able to use address sanitizer (You can ignore this part if there is no address sanitizer error) On Ubuntu 24.04, the commands to compile were:

bash
rustup default nightly
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
rustup component add llvm-tools-preview --toolchain nightly-x86_64-unknown-linux-gnu

export RUST_BACKTRACE=1 # or full depending on project
export ASAN_SYMBOLIZER_PATH=$(which llvm-symbolizer-18)
export ASAN_OPTIONS=symbolize=1
RUSTFLAGS="-Zsanitizer=address" cargo +nightly build --target x86_64-unknown-linux-gnu

cause this

Checking file: /opt/BROKEN_FILES_DIR/regress-crbug-691194_IDX_0_RAND_754750803321121967968990_minimized_687.js

memory allocation of 25769803776 bytes failed
stack backtrace:
   0: std::alloc::rust_oom
             at /rustc/7c3c88f42ad444f4688b865591d84660be4ece2f/library/std/src/alloc.rs:424:5
   1: __rustc::__rust_alloc_error_handler
             at /rustc/7c3c88f42ad444f4688b865591d84660be4ece2f/library/std/src/alloc.rs:423:1
   2: alloc::alloc::handle_alloc_error::rt_error
             at /rustc/7c3c88f42ad444f4688b865591d84660be4ece2f/library/alloc/src/alloc.rs:551:13
   3: alloc::alloc::handle_alloc_error
             at /rustc/7c3c88f42ad444f4688b865591d84660be4ece2f/library/alloc/src/alloc.rs:557:9
   4: alloc::raw_vec::handle_error
             at /rustc/7c3c88f42ad444f4688b865591d84660be4ece2f/library/alloc/src/raw_vec/mod.rs:890:38
   5: <alloc::raw_vec::RawVecInner>::with_capacity_in
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/raw_vec/mod.rs:442:25
   6: <alloc::raw_vec::RawVec<boa_string::str::JsStr>>::with_capacity_in
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/raw_vec/mod.rs:177:20
   7: <alloc::vec::Vec<boa_string::str::JsStr>>::with_capacity_in
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:977:20
   8: <alloc::vec::Vec<boa_string::str::JsStr>>::with_capacity
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:524:9
   9: <boa_engine::builtins::string::String>::repeat
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/builtins/string/mod.rs:737:26
  10: <boa_engine::native_function::NativeFunction>::call
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/native_function/mod.rs:303:36
  11: boa_engine::native_function::native_function_call
  12: <boa_engine::object::internal_methods::CallValue>::resolve
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/object/internal_methods/mod.rs:496:28
  13: <boa_engine::vm::opcode::call::Call>::operation
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/opcode/call/mod.rs:196:48
  14: boa_engine::vm::opcode::handle_call
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/opcode/mod.rs:370:17
  15: <boa_engine::context::Context>::run::{closure#0}
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/mod.rs:1004:21
  16: <boa_engine::context::Context>::execute_instruction::<<boa_engine::context::Context>::run::{closure#0}>
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/mod.rs:774:9
  17: <boa_engine::context::Context>::execute_one::<<boa_engine::context::Context>::run::{closure#0}>
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/mod.rs:800:14
  18: <boa_engine::context::Context>::run
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/vm/mod.rs:999:24
  19: <boa_engine::script::Script>::evaluate
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/script.rs:178:30
  20: <boa_engine::context::Context>::eval::<boa_parser::source::utf8::UTF8Input<&[u8]>>
             at /home/runner/.cargo/git/checkouts/boa-126d820dff07bf57/3ce87f0/core/engine/src/context/mod.rs:206:41
  21: boa::check_file
             at ./crates/boa/src/main.rs:34:27
  22: boa::main
             at ./crates/boa/src/main.rs:23:9
  23: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
timeout: the monitored command dumped core

##### Automatic Fuzzer note, output status "None", output signal "Some(6)"

compressed.zip