Skip to content

Fix Windows Debug crash caused by cross-allocator free of Rust inputfile strings#2129

Merged
cfsmp3 merged 2 commits intoCCExtractor:masterfrom
rhythmcache:rhythmcache-patch-2
Feb 20, 2026
Merged

Fix Windows Debug crash caused by cross-allocator free of Rust inputfile strings#2129
cfsmp3 merged 2 commits intoCCExtractor:masterfrom
rhythmcache:rhythmcache-patch-2

Conversation

@rhythmcache
Copy link
Contributor

This PR fixes a crash that occurs on Windows Debug builds when freeing inputfile inside dinit_libraries().

Problem:

  • inputfile strings and the pointer array are allocated in Rust using CString::into_raw() and Vec.
    They were later freed in C using free(), which caused a cross-allocator mismatch.
    on msvc debug builds this triggered a _CrtIsValidHeapPointer assertion.

FIx:
Replaced the manual free() calls in dinit_libraries() with
free_rust_c_string_array(), ensuring Rust-allocated memory is freed using Rust’s allocator.

The Rust function is exported with extern "C" to allow proper linkage from C.

Testing:

  • Verified on Windows x64 Debug build

  • No _CrtIsValidHeapPointer assertion

  • Tested with single and multiple input files

On Windows Debug builds, freeing inputfile in dinit_libraries()
causes a _CrtIsValidHeapPointer assertion failure.

The root cause was that the inputfile strings and the array are allocated in Rust using CString::into_raw() and Vec, which use Rust's global allocator.
They were later freed in C using free(), causing a cross-allocator
mismatch detected by the MSVC Debug CRT. The fix is to replace manual free() calls with free_rust_c_string_array() so that
rust allocated memory is released using the correct allocator.
@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 2dc5cf3...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 85/86
Teletext 21/21
WTV 13/13
XDS 34/34

Your PR breaks these cases:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never

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.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 185631d...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 85/86
Teletext 21/21
WTV 13/13
XDS 34/34

Your PR breaks these cases:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never

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.

@cfsmp3 cfsmp3 merged commit 6f7ce27 into CCExtractor:master Feb 20, 2026
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants