0.6.6: lambdas that capture a throwing copy terminate under /Zc:lambda; audit the in-game tree
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 46/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cmake, cpp
- Domain
- backend, testing-qa
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 12
- Forks
- 2
- Avg merge
- 3h 10m
- Merged PRs (30d)
- 171
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phantoslayer21/wronggpu
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
phantoslayer21/wronggpu#275 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
phantoslayer21/wronggpu#274 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
phantoslayer21/wronggpu#241 ·
Maintainers usually reply within 1 day
-
bug build
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
phantoslayer21/wronggpu#234 ·
Maintainers usually reply within 1 day
-
bug build
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
phantoslayer21/wronggpu#233 ·
Maintainers usually reply within 1 day
All issues in phantoslayer21/wronggpu
Similar issues
-
ai_p2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ClickHouse/ClickHouse#132519 ·
Maintainers usually reply within 1 day
-
[Bug]: VST3 getMidiControllerAssignment reads past midiControllerToParameter for program changeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
juce-framework/JUCE#1810 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
petercorke/robotics-toolbox-python#952 ·
Maintainers usually reply within 1 day
-
NatronRenderer: a Python error in the script (-t / project script) doesn't change the exit statusOpenfunc:engine type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#1276 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day