NGX provider: a call waiting on the lock can hang after another call faults
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
- 30/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- computer-graphics
Línea de trabajo
Start in clean/rr_f/proxy/src/hook_dll.cpp at the __except handler (around line 1365, ngx_fault) and the trampolines (1401-1427), then read the mu_ lock sites in clean/rr_f/proxy/src/ngx_rr.cpp (245, 363, 613, 630). The test goes in test_hook_dll with the fake runtime, which is not yet reproduced. Done means a second thread blocked on mu_ returns within a timeout after a faulting evaluate, with a test that asserts this.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This was found by reading the code. It has not been reproduced.
What happens
create, evaluate, release and release_all of the NGX provider each take a std::lock_guard<std::recursive_mutex> on mu_ (clean/rr_f/proxy/src/ngx_rr.cpp:245, 363, 613, 630).
The trampolines in clean/rr_f/proxy/src/hook_dll.cpp check g_ngx_faulted only before entering (hook_dll.cpp:1401-1427). The __except handler calls ngx_fault (hook_dll.cpp:1365), which closes the command-list bracket and sets the flag. Nothing else. The code's own comment (hook_dll.cpp:1356-1361) says the lock may stay held by the faulting thread after a structured exception, so nothing takes it any more. That holds only for calls that arrive after the flag is set.
The plugin is built with /EHsc (clean/rr_f/proxy/tools/build.py). With /EHsc, destructors of automatic objects are not guaranteed to run when an asynchronous (structured) exception is caught. So the lock_guard may not unlock. A fault inside a runtime function called through a C function-pointer table is the likely case.
A second thread already blocked on mu_ when the fault happens may then wait forever. If unwinding does release the lock, the waiter enters possibly corrupt provider state without rechecking the flag. That second fault would be caught by its own trampoline.
No other path takes mu_ after init. set_cmd_list_bracket is only called from OptiPluginInit, and the route guard uses the lock-free live().
When it can happen
Needs two things: a fault inside the provider or the runtime (itself a bug), and a second NGX call from another thread already waiting on mu_ at that moment. For example, a release on a loading or shutdown thread while the render thread evaluates. It turns a fault the design says is recoverable (the game falls back) into a game hang. Medium severity: it only follows another defect, but a hang is worse than the fallback.
To do
Preferred, lower risk:
- In the trampolines, replace the blocking lock with a
try_lockloop withSleep(0)that exits wheng_ngx_faultedbecomes true.
Also:
- In
NgxRrProvider::create,evaluateandrelease, right after taking the lock, return the failure value if a provider-levelfaulted_atomic is set (shared withg_ngx_faulted).
Alternative: in each __except handler (it runs on the faulting thread, the owner), set the flag first, then release the mutex as many times as that thread holds it. Track the depth in a thread_local.
Caution: unlocking from a handler must use the exact recursion depth, or the mutex is left inconsistent. The try_lock loop is simpler.
Test
CPU-only, in test_hook_dll (release build) with the fake runtime. Make the fake runtime's evaluate block on an event and then fault. Start a second thread that calls release through the NGX table, so it waits on mu_. Signal the event. Assert the second thread returns within a timeout.
- Lenguaje dominante
- C++
- Estrellas
- 12
- Forks
- 2
- Merge medio
- 3 h 10 min
- PR fusionados (30 d)
- 171
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 phantoslayer21/wronggpu
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
phantoslayer21/wronggpu#275 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
phantoslayer21/wronggpu#274 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
phantoslayer21/wronggpu#241 ·
Los mantenedores suelen responder en 1 día
-
bug build
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
phantoslayer21/wronggpu#234 ·
Los mantenedores suelen responder en 1 día
-
Launcher tests: "an older record: update available" fakes a version newer than the test buildAbiertobug build
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
phantoslayer21/wronggpu#233 ·
Los mantenedores suelen responder en 1 día
Todos los issues de phantoslayer21/wronggpu
Issues similares
-
ai_p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ClickHouse/ClickHouse#132519 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: VST3 getMidiControllerAssignment reads past midiControllerToParameter for program changeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
juce-framework/JUCE#1810 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
petercorke/robotics-toolbox-python#952 ·
Los mantenedores suelen responder en 1 día
-
NatronRenderer: a Python error in the script (-t / project script) doesn't change the exit statusAbiertofunc:engine type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NatronGitHub/Natron#1276 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día