Error contexts sent through futures/streams aren't reference-counted
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start in crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs, especially lower_error_context_to_index, and compare its reference-count handling with error_context_transfer. Reproduce the supplied WAST case with component-model-error-context enabled, then trace the error-context lifetime through future and stream payloads. Done means the receiver can drop its copy and the sender can still drop its handle without a bug or stale slot reuse.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This input:
;;! component_model_async = true
;;! component_model_error_context = true
;; `$B` sends an error-context to `$A` through a future, and `$A` drops the
;; copy it received. `$B` still owns its own handle, so dropping it should
;; succeed.
(component
(component $A
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(type $FT (future error-context))
(core func $future.read
(canon future.read $FT async (memory (core memory $libc "memory"))))
(core func $error-context.drop (canon error-context.drop))
(core module $m
(import "libc" "memory" (memory 1))
(import "" "future.read" (func $future.read (param i32 i32) (result i32)))
(import "" "error-context.drop" (func $error-context.drop (param i32)))
(func (export "take") (param $f i32)
(if (i32.ne (call $future.read (local.get $f) (i32.const 0))
(i32.const 0 (; COMPLETED ;)))
(then unreachable))
(call $error-context.drop (i32.load (i32.const 0))))
)
(core instance $i (instantiate $m
(with "libc" (instance $libc))
(with "" (instance
(export "future.read" (func $future.read))
(export "error-context.drop" (func $error-context.drop))))))
(func (export "take") (param "f" $FT) (canon lift (core func $i "take"))))
(instance $a (instantiate $A))
(component $B
(import "take" (func $take (param "f" (future error-context))))
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(type $FT (future error-context))
(core func $take (canon lower (func $take)))
(core func $future.new (canon future.new $FT))
(core func $future.write
(canon future.write $FT async (memory (core memory $libc "memory"))))
(core func $error-context.new
(canon error-context.new (memory (core memory $libc "memory"))))
(core func $error-context.drop (canon error-context.drop))
(core module $m
(import "libc" "memory" (memory 1))
(import "" "take" (func $take (param i32)))
(import "" "future.new" (func $future.new (result i64)))
(import "" "future.write" (func $future.write (param i32 i32) (result i32)))
(import "" "error-context.new" (func $error-context.new (param i32 i32) (result i32)))
(import "" "error-context.drop" (func $error-context.drop (param i32)))
(func (export "run")
(local $futures i64) (local $e i32)
(local.set $e (call $error-context.new (i32.const 0) (i32.const 0)))
(local.set $futures (call $future.new))
(i32.store (i32.const 0) (local.get $e))
(if (i32.ne (call $future.write
(i32.wrap_i64 (i64.shr_u (local.get $futures) (i64.const 32)))
(i32.const 0))
(i32.const -1 (; BLOCKED ;)))
(then unreachable))
(call $take (i32.wrap_i64 (local.get $futures)))
(call $error-context.drop (local.get $e)))
)
(core instance $i (instantiate $m
(with "libc" (instance $libc))
(with "" (instance
(export "take" (func $take))
(export "future.new" (func $future.new))
(export "future.write" (func $future.write))
(export "error-context.new" (func $error-context.new))
(export "error-context.drop" (func $error-context.drop))))))
(func (export "run") async (canon lift (core func $i "run"))))
(instance $b (instantiate $B (with "take" (func $a "take"))))
(export "run" (func $b "run"))
)
(assert_return (invoke "run"))
fails with
$ wasmtime wast -W component-model-error-context=y repro.wast
Error: failed to run script file 'repro.wast'
0: failed directive on repro.wast:78
1: error while executing at wasm backtrace:
2: BUG: retrieve concurrent state for error context during drop
An LLM summary, if useful, is:
When an error-context is lowered as part of a future or stream payload,
lower_error_context_to_index
(crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs)
inserts it into the receiving component's table without incrementing
global_error_context_ref_counts. The direct transfer path,
error_context_transfer, does increment it.
So if a component sends an error-context through a future and the receiver
drops its copy, the global count goes from 1 to 0 and the shared state is
deleted while the sender still has a handle. The sender dropping its handle
then hits a bail_bug!. If another error-context is created first, it
reuses the freed slot, and the sender's handle refers to that one instead,
which may belong to a different component.
This requires component-model-error-context, which is off by default.
- Lenguaje dominante
- Rust
- Estrellas
- 18.9k
- Forks
- 2k
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 238
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 bytecodealliance/wasmtime
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
bytecodealliance/wasmtime#15536 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
bytecodealliance/wasmtime#15455 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
wasi-preview1-component-adapter: fd_write does not invalidate cached InputStream, causing stale readsPosiblemente ocupada @dpfens la tomó hace 13 días. Abiertowasi
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bytecodealliance/wasmtime#15296 ·
Los mantenedores suelen responder en 1 día
-
bug wasm-proposal:exceptions wasmtime:debugging
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bytecodealliance/wasmtime#14102 ·
Los mantenedores suelen responder en 1 día
-
wasm-proposal:gc
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
bytecodealliance/wasmtime#13808 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de bytecodealliance/wasmtime
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
area: plugins bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
clipy-recorder/clipy#1039 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
valkey-io/valkey-glide#7975 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
gofractally/psibase#2379 ·
Los mantenedores suelen responder en 3 días
-
Qwen stream parser: a chunk with "error": null is treated as a stream errorPosiblemente ocupada @Beehtrix la tomó hoy. Abiertoarea:models bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
brekkylab/ailoy#681 · 1 comentario ·
Los mantenedores suelen responder en 2 días