alloy-rs / alloy-rs/alloy

[Bug] Blob type being stack allocated leads to easy stack overflows

Abierto
#2,772 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Rust
Estrellas
1.3k
Forks
668
Merge medio
2 d 1 h
PR fusionados (30 d)
29

Descripción

### Component

consensus, eips, genesis

### What version of Alloy are you on?

1.0.24

### Operating System

None

### Describe the bug

I noticed some stack overflows with some tests I had written. The culprit is from this type in alloy-eips
```
/// A Blob serialized as 0x-prefixed hex string
pub type Blob = FixedBytes;
```
With `BYTES_PER_BLOB = 131_072` and FixedBytes being stack allocated it seems like alot to put on the stack and can easily overflow it in some situations especially if it ends up getting cloned a couple times. This simple test below will stack overflow on Arch and MacOs ive tested(in debug mode)

```
use alloy_rpc_types_engine::BlobsBundleV2;
use ssz::Encode as _;

#[test]
fn test() {
let blobs_bundle = BlobsBundleV2 {
commitments: vec![Default::default()],
proofs: vec![Default::default()],
blobs: vec![Default::default()],
};

let bytes = blobs_bundle.as_ssz_bytes();
// following line will stack overflow
let blob: BlobsBundleV2 = ssz::Decode::from_ssz_bytes(&bytes).unwrap();
}
```

Maybe we can Box<> this type to avoid these overflows?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.