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

Function alloc_str could be capacity overflow #16

Open
cicilzx opened this issue Oct 6, 2024 · 0 comments
Open

Function alloc_str could be capacity overflow #16

cicilzx opened this issue Oct 6, 2024 · 0 comments

Comments

@cicilzx
Copy link

cicilzx commented Oct 6, 2024

Hi, I'm developing a fuzzer to test the safe abstraction, and I fonnd a segmentation fault when calling function src/lib/alloc_str().

This is a test case:

#[allow(warnings, unused)]
#[test]
fn test_alloc_str_jsItp() {
    let len: usize = 10830581488692310795;
    let _ = alloc_str(len);
}

Also, because it's a public API, if call this API directly like this:

use triple_accel;

fn main() {
    let len: usize = 10830581488692310795;
    let _ = triple_accel::alloc_str(len);
}

The output is as follows:

---- test_alloc_str_jsItp stdout ----
len = 10830581488692310795
thread 'test_alloc_str_jsItp' panicked at library/alloc/src/raw_vec.rs:25:5:
capacity overflow
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/core/src/panicking.rs:72:14
   2: alloc::raw_vec::capacity_overflow
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/alloc/src/raw_vec.rs:25:5
   3: alloc::raw_vec::handle_error
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/alloc/src/raw_vec.rs:593:29
   4: alloc::raw_vec::RawVec<T,A>::with_capacity_zeroed_in
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/alloc/src/raw_vec.rs:178:25
   5: <T as alloc::vec::spec_from_elem::SpecFromElem>::from_elem
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/alloc/src/vec/spec_from_elem.rs:25:31
   6: alloc::vec::from_elem
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/alloc/src/vec/mod.rs:2739:5
   7: triple_accel::alloc_str
             at ./src/lib.rs:199:17
   8: triple_accel::test_alloc_str_jsItp
             at ./src/lib.rs:262:13
   9: triple_accel::test_alloc_str_jsItp::{{closure}}
             at ./src/lib.rs:247:26
  10: core::ops::function::FnOnce::call_once
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/core/src/ops/function.rs:250:5
  11: core::ops::function::FnOnce::call_once
             at /rustc/d84b9037541f45dc2c52a41d723265af211c0497/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant