0.6.6: lambdas that capture a throwing copy terminate under /Zc:lambda; audit the in-game tree
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 46/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- cmake, cpp
- Bereich
- backend, testing-qa
Rechercherichtung
Start with clean/fsr/src/dllmain.cpp and compare its modelPlaces capture with DeviceRelease in clean/fsr/src/async_create.h; then audit the in-game tree listed in the issue for other throwing lambda captures. Read the contributor notes for the existing code rules and inspect TestDeviceHoldAllocationFailure in clean/fsr/tests/test_frontend.cpp. Done means all identified sites follow the proposed rule, the rule is documented, and the relevant throwing-copy test passes in the CI configuration.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What
With MSVC's /Zc:lambda, a lambda whose capture copy throws terminates the process (std::terminate) instead of unwinding to the caller's handler. /Zc:lambda is on whenever /permissive- is, and the CMake targets of the front end build with /permissive-, so every release build of the in-game code has it on. A capture copy can throw whenever the captured object allocates when it is copied (std::string, std::vector, std::function holding a large callable): the throw is std::bad_alloc, so the case is out of memory, and the process ends in std::terminate instead of the error path.
It was found in the create worker's device hold (#225): [release, device] { release(device); } captured a std::function by copy. A test with a callable whose copy throws aborted with exit code 0xc0000409 in the CI configuration (cmake, Release, /permissive- /W4 /Zi) and not in a hand-made cl build without /permissive-. A stand-alone reproduction narrowed it to this switch: with /Zc:lambda alone the throw terminates, without it the exception reaches the catch; a plain copy of the same std::function (no lambda) is fine in every configuration.
Rule (proposed)
No lambda in code that runs in a game may capture, by copy or by init-capture, an object whose copy can throw. Use one of:
- a named callable class whose constructor does the copy (that unwinds normally; #225 does this:
DeviceReleaseinclean/fsr/src/async_create.h), or - a capture whose copy cannot throw: a raw pointer, an index, a
std::shared_ptr(copy isnoexcept), or astd::moveinto an init-capture of a type with anoexceptmove.
Known site
clean/fsr/src/dllmain.cpp: p.modelPlaces = [modelDir = config.modelDir] { ... } init-captures a std::string by copy at start-up. Out of memory at that point ends in std::terminate instead of the normal failure. It is the same class; it is not part of #225.
Asked for (0.6.6)
- Audit the whole in-game tree (front end, the D3D12 runtime and its interop, the Ray Reconstruction plugin and runtime, shared code that runs in the game process) for lambdas with a by-copy or init-capture of a type whose copy can throw; fix each as above.
- Write the rule in the contributor notes next to the other code rules.
- Optional: a small CI check (a grep for init-captures of
std::string/std::vector/std::functionin the in-game sources) so the rule holds. - Keep a test that drives a throwing copy through any callable the fix touches (see
TestDeviceHoldAllocationFailureinclean/fsr/tests/test_frontend.cpp): it must pass in the CI configuration.
- Vorherrschende Sprache
- C++
- Sterne
- 12
- Forks
- 2
- Ø Merge
- 3 Std. 10 Min.
- Gemergte PRs (30 T.)
- 171
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus phantoslayer21/wronggpu
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
phantoslayer21/wronggpu#275 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
phantoslayer21/wronggpu#274 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
phantoslayer21/wronggpu#241 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug build
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
phantoslayer21/wronggpu#234 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug build
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
phantoslayer21/wronggpu#233 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in phantoslayer21/wronggpu
Ähnliche Issues
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
ReyeMe/SaturnRingLib#155 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Nheko-Reborn/nheko#2092 ·
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
isocpp/CppCoreGuidelines#2345 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 71/100
ROCm/rocm-libraries#16108 ·
Maintainer antworten meist innerhalb von 2 Tagen