Repository navigation
Description
Description
rsgain 3.8 crashes on Windows when scanning a file with a non-ASCII filename while stdout is attached directly to a CP936 console.
The filename is first displayed as mojibake, then the process exits with 0xC0000409.
This appears to be a regression from rsgain 3.7.
Environment
- Windows:
Windows 11 26300.9457 - System locale / culture:
zh-CN - Console code page:
936 - PowerShell
- rsgain 3.8 official Windows binary:
- MSVC 19.51
- Build date: 2026-09-02
Minimal reproduction
Use any valid audio file and give it a non-ASCII filename, for example:
ひとひら - 秦基博.mp3
With the console using CP936:
chcp 936
rsgain custom -s s ".\ひとひら - 秦基博.mp3"
$code = $LASTEXITCODE
$u = [BitConverter]::ToUInt32(
[BitConverter]::GetBytes([int32]$code), 0
)
"Exit: $code / 0x{0:X8}" -f $uActual result
[OK] Scanning '.\銇层仺銇层倝 - 绉﹀熀鍗?mp3'
The process immediately exits:
Exit: -1073740791 / 0xC0000409
No container or stream information is printed.
Expected result
The filename should be displayed correctly and the scan should complete normally.
Control tests
The same rsgain 3.8 binary and the same audio file behave as follows:
| Test | Result |
|---|---|
Rename file to ascii-test.mp3, CP936, direct console |
Works |
Unicode filename, chcp 65001 |
Works; filename is displayed correctly |
Unicode filename, CP936, stdout piped through Tee-Object |
Works, but filename is mojibake |
Unicode filename with -q |
Works |
| rsgain 3.7 under the original CP936 environment | Works |
For example, after:
chcp 65001
[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
rsgain custom -s s ".\ひとひら - 秦基博.mp3"rsgain 3.8 completes normally and displays:
[OK] Scanning '.\ひとひら - 秦基博.mp3'
[OK] Container: MP2/3 (MPEG audio layer 2/3) [mp3]
[OK] Stream #0: MP3 (MPEG audio layer 3), 44100 Hz, 2 ch
...
Piping stdout also prevents the crash:
rsgain custom -s s ".\ひとひら - 秦基博.mp3" |
Tee-Object ".\rsgain-test.txt"but the filename is still displayed as mojibake.
Additional notes
This seems to point to the Windows console output path rather than file access or FFmpeg decoding, since -q, redirected stdout, and code page 65001 all allow the same Unicode file to be scanned successfully.
This may be related to the Windows console/CRT behavior discussed in #185 / #188, although the trigger appears different: this crash occurs immediately while printing the non-ASCII filename, before the container/stream output.
Activity