D3D12-HLE-AUDIO-CAPTURE-OVERFLOW-AND-HANDLES: fix WAV header/QPC overflows and close process/COM state #3001

Open
bobcatchris wants to merge 2 commits from upstream-pr/3001 into main
bobcatchris commented 2026-12-01 23:05:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T23:05:44Z.


Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7328655440.

Changes (d3d12/crates/leonida-hle/src/modules/audio/capture.rs)

  1. Fix WAV header(frames) overflow panic:
    • Use frames.saturating_mul(FRAME_BYTES as u64) and clamp data to MAX_RIFF_DATA = u32::MAX - 36.
    • Previously, frames in 1_073_741_815..=1_073_741_823 fit u32::try_from(frames * 4) with data > u32::MAX - 36, causing 36 + data to panic with u32 addition overflow in debug builds (and wrap in release builds), while frames > u64::MAX / 4 panicked on frames * 4.
  2. Prevent QPC underflow/overflow panics:
    • Extract packet_frame(&mut first, qpc) using qpc.saturating_sub(origin) and u128 multiplication before dividing by 10_000_000.
  3. Close OpenProcess handle and uninitialize COM on exit:
    • Wrap the OpenProcess HANDLE in ProcessHandle (CloseHandle on Drop) and CoInitializeEx in ComGuard (CoUninitialize on Drop, ordered after all COM interfaces and ProcessHandle), closing both on early Err returns and normal exit.

Verification

  • Red -> Green:
    • header_caps_riff_size_without_overflow fails (exit 101) with unguarded frames * 4 / 36 + data; passes with clamp.
    • packet_frame_handles_non_monotonic_and_large_qpc fails (exit 101) with unchecked subtraction/multiplication; passes with packet_frame.
    • process_handle_drop_closes_opened_process_handle fails (exit 101) with CloseHandle stubbed in Drop; passes in an isolated subprocess checking GetHandleInformation == 0.
  • cargo test --locked -p leonida-hle --lib --features diagnostics -- modules::audio::capture::tests: 3 passed, 0 failed.
  • cargo test --locked -p leonida-hle --lib -- modules::audio::tests: 8 passed, 0 failed.
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/audio/capture.rs: exit 0.
  • Independent read-only code review: approved.

AI-assisted

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5596275231 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T23:05:44Z. --- Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7328655440. ### Changes (`d3d12/crates/leonida-hle/src/modules/audio/capture.rs`) 1. **Fix WAV `header(frames)` overflow panic**: - Use `frames.saturating_mul(FRAME_BYTES as u64)` and clamp `data` to `MAX_RIFF_DATA = u32::MAX - 36`. - Previously, `frames` in `1_073_741_815..=1_073_741_823` fit `u32::try_from(frames * 4)` with `data > u32::MAX - 36`, causing `36 + data` to panic with `u32` addition overflow in debug builds (and wrap in release builds), while `frames > u64::MAX / 4` panicked on `frames * 4`. 2. **Prevent QPC underflow/overflow panics**: - Extract `packet_frame(&mut first, qpc)` using `qpc.saturating_sub(origin)` and `u128` multiplication before dividing by `10_000_000`. 3. **Close `OpenProcess` handle and uninitialize COM on exit**: - Wrap the `OpenProcess` `HANDLE` in `ProcessHandle` (`CloseHandle` on `Drop`) and `CoInitializeEx` in `ComGuard` (`CoUninitialize` on `Drop`, ordered after all COM interfaces and `ProcessHandle`), closing both on early `Err` returns and normal exit. ### Verification - **Red -> Green**: - `header_caps_riff_size_without_overflow` fails (`exit 101`) with unguarded `frames * 4` / `36 + data`; passes with clamp. - `packet_frame_handles_non_monotonic_and_large_qpc` fails (`exit 101`) with unchecked subtraction/multiplication; passes with `packet_frame`. - `process_handle_drop_closes_opened_process_handle` fails (`exit 101`) with `CloseHandle` stubbed in `Drop`; passes in an isolated subprocess checking `GetHandleInformation == 0`. - `cargo test --locked -p leonida-hle --lib --features diagnostics -- modules::audio::capture::tests`: 3 passed, 0 failed. - `cargo test --locked -p leonida-hle --lib -- modules::audio::tests`: 8 passed, 0 failed. - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: exit 0. - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/audio/capture.rs`: exit 0. - Independent read-only code review: approved. AI-assisted
andrew-ai commented 2026-12-01 23:09:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T23:09:08Z.


The clamp avoids the integer overflow, but the capped data chunk ends three bytes into a four-byte PCM frame. I compiled header() and its constants unchanged at ffe91287b and decoded the emitted 44-byte headers:

Input frames Block alignment Declared data bytes Remainder
1,073,741,814 4 4,294,967,256 0
1,073,741,815 4 4,294,967,259 3
u64::MAX 4 4,294,967,259 3

Rounding the cap down to the largest whole frame gives 4,294,967,256 data bytes and a RIFF size of 4,294,967,292. An assertion that data_size % block_align == 0 at the last representable frame and one beyond would cover the boundary. This reproduction only generated headers. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328905068 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7328905068). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T23:09:08Z. --- The clamp avoids the integer overflow, but the capped data chunk ends three bytes into a four-byte PCM frame. I compiled header() and its constants unchanged at ffe91287b and decoded the emitted 44-byte headers: | Input frames | Block alignment | Declared data bytes | Remainder | | --- | ---: | ---: | ---: | | 1,073,741,814 | 4 | 4,294,967,256 | 0 | | 1,073,741,815 | 4 | 4,294,967,259 | 3 | | u64::MAX | 4 | 4,294,967,259 | 3 | Rounding the cap down to the largest whole frame gives 4,294,967,256 data bytes and a RIFF size of 4,294,967,292. An assertion that data_size % block_align == 0 at the last representable frame and one beyond would cover the boundary. This reproduction only generated headers. Codex-assisted.
bobcatchris commented 2026-12-01 23:10:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T23:10:48Z.


Updated in fast-forward commit d924cbb65 to address the frame-alignment boundary noted by @andrew-ai:

  • Round MAX_RIFF_DATA down to whole FRAME_BYTES-byte PCM frames (((u32::MAX - 36) / FRAME_BYTES as u32) * FRAME_BYTES as u32 = 4_294_967_256 bytes, RIFF size 4_294_967_292 bytes), so the capped data chunk never ends partway through a 4-byte stereo 16-bit frame.
  • Updated header_caps_riff_size_without_overflow to assert data_size == MAX_RIFF_DATA, data_size % FRAME_BYTES as u32 == 0, and riff_size == 36 + MAX_RIFF_DATA at 1_073_741_814, 1_073_741_815, and up through u64::MAX.

Re-verified cargo test --locked -p leonida-hle --lib --features diagnostics -- modules::audio::capture::tests (3 passed, 0 failed), default-feature modules::audio::tests (8 passed, 0 failed), d3d12_switches.py --check, and check_no_game_data.py.

AI-assisted

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328957492 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7328957492). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T23:10:48Z. --- Updated in fast-forward commit `d924cbb65` to address the frame-alignment boundary noted by @andrew-ai: - Round `MAX_RIFF_DATA` down to whole `FRAME_BYTES`-byte PCM frames (`((u32::MAX - 36) / FRAME_BYTES as u32) * FRAME_BYTES as u32` = `4_294_967_256` bytes, RIFF size `4_294_967_292` bytes), so the capped data chunk never ends partway through a 4-byte stereo 16-bit frame. - Updated `header_caps_riff_size_without_overflow` to assert `data_size == MAX_RIFF_DATA`, `data_size % FRAME_BYTES as u32 == 0`, and `riff_size == 36 + MAX_RIFF_DATA` at `1_073_741_814`, `1_073_741_815`, and up through `u64::MAX`. Re-verified `cargo test --locked -p leonida-hle --lib --features diagnostics -- modules::audio::capture::tests` (`3 passed, 0 failed`), default-feature `modules::audio::tests` (`8 passed, 0 failed`), `d3d12_switches.py --check`, and `check_no_game_data.py`. AI-assisted
andrew-ai commented 2026-12-01 23:11:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T23:11:35Z.


Confirmed the frame-alignment fix in d924cbb65 by compiling header() from both revisions and independently decoding its output. At 1,073,741,813 and 1,073,741,814 frames the data sizes remain 4,294,967,252 and 4,294,967,256. At the next frame and at u64::MAX the revised header stays at 4,294,967,256 data bytes and 4,294,967,292 RIFF bytes. The old head declared three extra bytes in both cases. My header finding is resolved. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328982981 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7328982981). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T23:11:35Z. --- Confirmed the frame-alignment fix in d924cbb65 by compiling header() from both revisions and independently decoding its output. At 1,073,741,813 and 1,073,741,814 frames the data sizes remain 4,294,967,252 and 4,294,967,256. At the next frame and at u64::MAX the revised header stays at 4,294,967,256 data bytes and 4,294,967,292 RIFF bytes. The old head declared three extra bytes in both cases. My header finding is resolved. Codex-assisted.
MoonEyes commented 2026-12-02 12:34:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:34:59Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345555665 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7345555665). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:34:59Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:00:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:00:37Z.


Code review of head d924cbb65 (merge base 1abef08d0, 326 commits behind; merges cleanly into current main 45dc41f95). Not built here: leonida-hle's capture module and its tests are Windows-only. CI on this head is green, including d3d12 (windows-latest), which runs the new tests.

1 file: d3d12/crates/leonida-hle/src/modules/audio/capture.rs  +114/-6

The three fixes, read against main:

  1. header(frames): main computes frames * FRAME_BYTES as u64 (overflows for frames > u64::MAX / 4, a debug panic) and caps at u32::MAX - 36, after which 36 + data overflows the RIFF size for frames 1_073_741_815..=1_073_741_823. The PR uses saturating_mul and caps at MAX_RIFF_DATA = ((u32::MAX - 36) / 4) * 4 = 4_294_967_256, so 36 + data <= u32::MAX and the data chunk stays frame-aligned (the alignment point @andrew-ai raised, fixed in d924cbb65 and confirmed by him).
  2. packet_frame: main's (qpc - first) * RATE / 10_000_000 underflows on a non-monotonic QPC and can overflow the u64 product for large deltas; the PR uses saturating_sub and a u128 product. The final as u64 truncates only for deltas far beyond any real run.
  3. ProcessHandle closes the OpenProcess handle on every exit path (main leaked it), and ComGuard balances CoInitializeEx. _com is declared before target and the COM interfaces, so locals drop in reverse order and every interface is released before CoUninitialize. CoInitializeEx(...).ok()? returns early on failure, so no unbalanced uninitialize.

Red/green by reading (not run): on main's header, header_caps_riff_size_without_overflow panics at u64::MAX (multiply overflow in a debug test build) and at 1_073_741_815 (the 36 + data add); packet_frame_handles_non_monotonic_and_large_qpc cannot compile without the new function, and the 9_000_000 case is the underflow main has. process_handle_drop_closes_opened_process_handle re-runs itself in a child with --exact so the GetHandleInformation check on a closed handle cannot race with another test reusing the value; that is a sound way to test a close.

Nits (non-blocking): ProcessHandle::drop sets self.0 = HANDLE::default() after closing, which is dead (the value is dropped); MAX_RIFF_DATA could be computed from FRAME_BYTES in u32 once rather than cast twice.

@MoonEyes's render-path gate comment does not apply in substance: this is the optional process-loopback audio recorder, not the render path.

Verdict: ready (code review and green Windows CI; no independent Windows run of the final head beyond CI).

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353856957 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7353856957). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:00:37Z. --- **Code review of head `d924cbb65` (merge base `1abef08d0`, 326 commits behind; merges cleanly into current `main` `45dc41f95`). Not built here: `leonida-hle`'s capture module and its tests are Windows-only. CI on this head is green, including `d3d12 (windows-latest)`, which runs the new tests.** ``` 1 file: d3d12/crates/leonida-hle/src/modules/audio/capture.rs +114/-6 ``` **The three fixes, read against `main`:** 1. `header(frames)`: `main` computes `frames * FRAME_BYTES as u64` (overflows for `frames > u64::MAX / 4`, a debug panic) and caps at `u32::MAX - 36`, after which `36 + data` overflows the RIFF size for frames `1_073_741_815..=1_073_741_823`. The PR uses `saturating_mul` and caps at `MAX_RIFF_DATA = ((u32::MAX - 36) / 4) * 4 = 4_294_967_256`, so `36 + data <= u32::MAX` and the data chunk stays frame-aligned (the alignment point @andrew-ai raised, fixed in `d924cbb65` and confirmed by him). 2. `packet_frame`: `main`'s `(qpc - first) * RATE / 10_000_000` underflows on a non-monotonic QPC and can overflow the `u64` product for large deltas; the PR uses `saturating_sub` and a `u128` product. The final `as u64` truncates only for deltas far beyond any real run. 3. `ProcessHandle` closes the `OpenProcess` handle on every exit path (`main` leaked it), and `ComGuard` balances `CoInitializeEx`. `_com` is declared before `target` and the COM interfaces, so locals drop in reverse order and every interface is released before `CoUninitialize`. `CoInitializeEx(...).ok()?` returns early on failure, so no unbalanced uninitialize. **Red/green by reading** (not run): on `main`'s `header`, `header_caps_riff_size_without_overflow` panics at `u64::MAX` (multiply overflow in a debug test build) and at `1_073_741_815` (the `36 + data` add); `packet_frame_handles_non_monotonic_and_large_qpc` cannot compile without the new function, and the `9_000_000` case is the underflow `main` has. `process_handle_drop_closes_opened_process_handle` re-runs itself in a child with `--exact` so the `GetHandleInformation` check on a closed handle cannot race with another test reusing the value; that is a sound way to test a close. **Nits (non-blocking):** `ProcessHandle::drop` sets `self.0 = HANDLE::default()` after closing, which is dead (the value is dropped); `MAX_RIFF_DATA` could be computed from `FRAME_BYTES` in `u32` once rather than cast twice. @MoonEyes's render-path gate comment does not apply in substance: this is the optional process-loopback audio recorder, not the render path. **Verdict: ready** (code review and green Windows CI; no independent Windows run of the final head beyond CI). AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-12-02 18:21:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:21:21Z.


RUN (in game, batch of seventeen render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3111 15b579756, #2948 5284c6eae, #2698 1f188c4f7, #2946 44bf554fe, #3001 d924cbb65, #2832 0c861595a, #2915 58e8535cf, #2822 d359a2f85, #2896 c9c6b103d, #2983 8278ef1b9, #3115 ba5121192, #2945 d2c08c14f, #2975 74512d658, #2951 26da88e8e, #2800 b6ebcedd4, #2893 7c7e99b48, #3113 fa1460b6b (and #3097 0d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (43 samples) median 14.6, mean 12.7
Rendered fps, last 120 s median 13.7
Time under 5 fps in the world 13 % (short drops, lowest sample 0.3 fps)

The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354433663 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7354433663). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:21:21Z. --- RUN (in game, batch of seventeen render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3111 `15b579756`, #2948 `5284c6eae`, #2698 `1f188c4f7`, #2946 `44bf554fe`, #3001 `d924cbb65`, #2832 `0c861595a`, #2915 `58e8535cf`, #2822 `d359a2f85`, #2896 `c9c6b103d`, #2983 `8278ef1b9`, #3115 `ba5121192`, #2945 `d2c08c14f`, #2975 `74512d658`, #2951 `26da88e8e`, #2800 `b6ebcedd4`, #2893 `7c7e99b48`, #3113 `fa1460b6b` (and #3097 `0d7a451ab`, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (43 samples) | median 14.6, mean 12.7 | | Rendered fps, last 120 s | median 13.7 | | Time under 5 fps in the world | 13 % (short drops, lowest sample 0.3 fps) | The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile. AI-assisted (Claude Code).
fiestorra commented 2026-12-03 04:58:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T04:58:15Z.


VERIFY-3001 — 8 tests de audio pasan, y el cambio ataca dos cosas en un fichero

d3d12/crates/leonida-hle/src/modules/audio/capture.rs   1 file changed, 114 insertions(+), 6 deletions(-)
cargo test -p leonida-hle --lib audio                   8 passed

El título nombra dos: cabecera WAV/QPC y handles — y son el mismo tipo de fallo visto desde dos sitios: un fichero .wav que se escribe con un tamaño de cabecera que no corresponde a lo que luego se escribe, y un HANDLE que se pierde en el camino.

Y la etiqueta OVERFLOW en el nombre es la pista de lo que importa: una captura que dura más de lo que la cabecera puede decir — el campo de tamaño de un WAV es de 32 bits y se escribe antes de saber el tamaño final, así que el patrón correcto es escribirlo al cerrar, no al abrir. Si el cambio hace eso, es el arreglo; si sólo añade un u64, es un parche que mueve el problema.

Lo que verifiqué: 8 tests de audio en verde — y capture.rs con 120 líneas añadidas sugiere que hay pruebas para las dos mitades.
Lo que no: una captura larga de verdad — necesita el juego emitiendo audio durante horas, y el desbordamiento de la cabecera es exactamente el caso que no aparece en un test de dos segundos.
Y la pregunta que le haría, en una línea: ¿el tamaño se escribe al cerrar o se calcula al abrir? La primera es la respuesta, la segunda el mismo bug con otro número.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368235505 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3001#issuecomment-7368235505). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T04:58:15Z. --- ## VERIFY-3001 — 8 tests de `audio` pasan, y el cambio ataca dos cosas en un fichero ``` d3d12/crates/leonida-hle/src/modules/audio/capture.rs 1 file changed, 114 insertions(+), 6 deletions(-) cargo test -p leonida-hle --lib audio 8 passed ``` **El título nombra dos**: **cabecera WAV/QPC** **y** **handles** — **y son el mismo tipo de fallo visto desde dos sitios**: **un fichero `.wav` que se escribe con un tamaño de cabecera que no corresponde a lo que luego se escribe**, **y un `HANDLE` que se pierde en el camino.** **Y la etiqueta `OVERFLOW` en el nombre es la pista de lo que importa**: **una captura que dura más de lo que la cabecera puede decir** — **el campo de tamaño de un WAV es de 32 bits y se escribe *antes* de saber el tamaño final**, **así que el patrón correcto es escribirlo al cerrar, no al abrir.** **Si el cambio hace eso, es el arreglo; si sólo añade un `u64`, es un parche que mueve el problema.** **Lo que verifiqué**: **8 tests de `audio` en verde** — **y `capture.rs` con 120 líneas añadidas sugiere que hay pruebas para las dos mitades**. **Lo que no**: **una captura larga de verdad** — **necesita el juego emitiendo audio durante horas, y el desbordamiento de la cabecera es exactamente el caso que no aparece en un test de dos segundos.** **Y la pregunta que le haría, en una línea**: **¿el tamaño se escribe al cerrar o se calcula al abrir?** **La primera es la respuesta, la segunda el mismo bug con otro número.**
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3001:upstream-pr/3001'
git switch 'upstream-pr/3001'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3001'
git switch 'upstream-pr/3001'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3001'
git switch 'upstream-pr/3001'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3001'
git switch 'main'
git merge --squash 'upstream-pr/3001'
git switch 'main'
git merge --ff-only 'upstream-pr/3001'
git switch 'main'
git merge 'upstream-pr/3001'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3001
No description provided.