GraphiteEditor / GraphiteEditor/Graphite
Context varargs can smuggle graph-runtime references past the borrow tree's lifetime discipline
- Lenguaje dominante
- Rust
- Estrellas
- 27.2k
- Forks
- 1.3k
- Merge medio
- 20 h 5 min
- PR fusionados (30 d)
- 57
Descripción
Reported by @TrueDoctor following the rank polymorphism PR (#4335). Three existing mechanisms combine into an unsound API surface:
1. The borrow tree launders lifetimes: `NodeContainer` derefs `*const TypeErasedNode<'static>` to `&'static`, so references handed out inside the graph (the `&PlatformEditorApi` scope wire, `&WgpuExecutor`, or any reference to node-owned state) are typed `'static` but actually live only until the next graph recompilation deallocates their owner.
2. `OwnedContextImpl::with_vararg` accepts any `Box`. Its `'static` bound cannot distinguish real ownership from a laundered reference, so safe code in any node can store such a reference into a context. #4335 made this channel idiomatic (render boundary config, per-item lambda rows).
3. Contexts escape the graph: the Monitor node snapshots `IORecord { input: Context, output }` into an `Arc` that the editor introspects and can retain across recompiles.
Combined: a node stores a laundered reference as a vararg, a Monitor captures the context, the graph recompiles and frees the referent, and the editor reads freed memory through entirely safe code (`vararg()` + `downcast_ref`). A vararg with interior mutability would similarly let context readers mutate graph-owned state as a covert return channel.
All current `with_vararg` callers box owned data, so no UB exists in the code today. But the risk remains for the API permitting it silently.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Start by tracing OwnedContextImpl::with_vararg, NodeContainer's lifetime handling, and the Monitor node's IORecord snapshot path, then review the rank polymorphism changes in #4335. Done means the context and vararg APIs no longer allow graph-runtime references to escape their valid lifetime, including across graph recompilation, without weakening safe-code guarantees.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- backend-api-design
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Tranquilo
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100