fix(rust): duplicate fresh strings bypass Limits::max_heap_bytes
Los mantenedores suelen responder en 1 día
@brxs ya está trabajando en esto.
Desde el 27/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Read rust/crates/psychoscript/src/heap.rs, focusing on heap::Walk::string and how Limits::max_heap_bytes is enforced. Run the minimal Rust test or the crate's memory-limit tests, then verify that separately allocated identical strings trigger DiagnosticKind::MemoryLimitExceeded without unbounded RSS growth.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
In the Rust crate (psychoscript 0.1.3 / dev), Limits::max_heap_bytes can be bypassed with separately allocated identical strings, allowing unbounded RSS growth under a small heap limit.
Cause
heap::Walk::string (rust/crates/psychoscript/src/heap.rs) deduplicates strings by (r.s, r.units) content via texts: FxHashSet<(&str, Option<&[u16]>)>:
let r = self.vm.atoms.sref(s);
if self.texts.insert((r.s, r.units)) {
self.bytes += STRING_BYTES + 2 * r.len16() as u64;
}
However, strings constructed dynamically (e.g. 'x'.repeat(10_000) or string concatenation) each allocate their own buffer and StrId in the string arena (vm.atoms.bufs). Because Walk::string only adds bytes for the first occurrence of a given text, holding 10,000 separately allocated copies of a 10,000-char string measures as ~20 KB instead of ~100+ MB and never trips MemoryLimitExceeded.
Minimal Reproduction
use psychoscript::{DiagnosticKind, Limits, Runtime};
#[test]
fn duplicate_fresh_strings_bypass_max_heap_bytes() {
let rt = Runtime::make().limits(Limits {
max_heap_bytes: Some(2 * 1024 * 1024),
..Limits::default()
});
let code = "const a = []; for (let i = 0; i < 10_000; i++) a.push('x'.repeat(10_000)); return a.length";
let outcome = rt.execute(code);
assert_eq!(
outcome.result.unwrap_err().kind,
DiagnosticKind::MemoryLimitExceeded
);
}
Observed: Completes with Ok(10000) and grows process RSS by ~103 MiB under a 2 MiB max_heap_bytes limit.
Expected: Stops with DiagnosticKind::MemoryLimitExceeded.
(Split out the separate BigInt max_heap_bytes issue into #113.)
- Lenguaje dominante
- Rust
- Estrellas
- 470
- Forks
- 11
- Merge medio
- 4 h 10 min
- PR fusionados (30 d)
- 89
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de anomalyco/psychoscript
-
fix(rust): large BigInts bypass Limits::max_heap_bytesPosiblemente ocupada @brxs la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
anomalyco/psychoscript#113 ·
Los mantenedores suelen responder en 1 día
-
fix(rust): Returned::Block deadlocks single-threaded async executors under execute_asyncPosiblemente ocupada @brxs la tomó hace 2 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
anomalyco/psychoscript#110 ·
Los mantenedores suelen responder en 1 día
-
Importing psychoscript throws RangeError in Safari (WebKit/JavaScriptCore)Posiblemente ocupada @vibdev la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
anomalyco/psychoscript#100 ·
Los mantenedores suelen responder en 1 día
-
Runs fail with `setImmediate is not defined` in browsers and Convex's runtime once a program runs longer than ~1 msPosiblemente ocupada @fengqiaoqu la tomó hace 2 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
anomalyco/psychoscript#82 ·
Los mantenedores suelen responder en 1 día
Todos los issues de anomalyco/psychoscript
Issues similares
-
bug good first issue web
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
triage: not actionable
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
oxc-project/oxc#30518 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: panel
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
frandev94/shattered-islands#98 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día