[FIX] Prevent MSVC cross-CRT invalid free on output_filename#2147
[FIX] Prevent MSVC cross-CRT invalid free on output_filename#2147Atul-Chahar wants to merge 2 commits intoCCExtractor:masterfrom
Conversation
cfsmp3
left a comment
There was a problem hiding this comment.
Two issues:
-
Unrelated SCC fps change: The SCC framerate fix is a duplicate of #2146. Please remove it from this PR.
-
Double free claim not substantiated: I ran valgrind on master with
--multiprogramand there is no "Invalid free" reported. Code analysis showsinit_encoderalways callsstrdupon the filename, sofreepin the cleanup path is correct — it frees the strdup'd copy, not the original. Removing thefreepactually introduces a small memory leak (the strdup'd 2 bytes are never freed).
Please provide concrete evidence of the double free (e.g. MSVC Debug output, valgrind trace, or a specific code path that skips the strdup). Without that, this change is incorrect.
43998f4 to
7b788d2
Compare
|
@cfsmp3 Thanks for the thorough review! I've updated the PR with an atomic fix addressing both of your points:
Specifically, The Correct Atomic Fix: Let me know what you think of this approach! |
…er_cfg - Removed premature freep on `ccx_options.enc_cfg.output_filename` since it is allocated by Rust via `CString::into_raw`, which causes CRT assertion failures on Windows Debug builds when freed by C's `free()`. - Used a local copy of `struct encoder_cfg` for dynamically generated filenames in `update_encoder_list_cinfo` and `segment_output_file` to avoid overwriting the Rust string pointer with a `malloc`'d string, successfully preventing memory leaks.
7b788d2 to
f3848e0
Compare
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit f377be9...:
Congratulations: Merging this PR would fix the following tests:
All tests passed completely. Check the result page for more info. |
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit f377be9...:
Your PR breaks these cases:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Summary
Resolves the Windows MSVC Debug build crash reported in #2126. The root cause was a cross-CRT boundary bug:
ccx_options.enc_cfg.output_filenameis allocated by Rust (CString::into_raw), but C code was callingfreep()on it — triggering the MSVC Debug allocator's invalid-free assertion.Fix
update_encoder_list_cinfo()andsegment_output_file()now work with a local copy (struct encoder_cfg local_cfg) for dynamic multi-program file allocations, keeping the global Rust-allocated pointer untouched. The crash-inducingfreep()call indinit_libraries()was also removed.Changes
src/lib_ccx/general_loop.c— use localencoder_cfgcopy for multi-program outputsrc/lib_ccx/lib_ccx.c— remove invalidfreep()on Rust-allocated string, fix cleanup pathdocs/CHANGES.TXT— added changelog entryCI Notes
The 9 Linux sample platform failures (
--autoprogram,--out=spupng,--startcreditstests) are pre-existing on upstream master and unrelated to this PR. The Windows sample platform confirms all 237/237 tests pass and this PR actually fixes those same 9 tests on Windows.Fixes #2126