stacks-network / clarity-wasm

`clar2wasm` is a compiler for generating WebAssembly from Clarity.
GNU General Public License v3.0
12 stars 9 forks source link

Function `map` can provoke OOM #411

Open Acaccia opened 1 month ago

Acaccia commented 1 month ago

It seems like map does not allocate space for its result, which might lead to OOM.

Here is an example of a failing program:

#[test]
fn foo() {
    let snippet = "(map + (list 1 2 3) (list 1 2 3) (list 1 2 3))".repeat(700);

    let expected = Value::Sequence(SequenceData::List(ListData {
        data: vec![Value::Int(3), Value::Int(6), Value::Int(9)],
        type_signature: ListTypeData::new_list(TypeSignature::IntType, 3).unwrap(),
    }));

    crosscheck(&snippet, Ok(Some(expected)))
}
smcclellan commented 1 month ago

Related to https://github.com/stacks-network/clarity-wasm/issues/407.