Repository navigation
Conversation
--videoedited runs general_loop() once per input and keeps the decoders and cap_info streams between inputs. Two pieces of per-file cleanup left stale state behind for the next input: - general_loop() freed dec_ctx->xds_ctx without clearing it. The next input used the freed context and freed it again (glibc aborts with "double free detected"). - cinfo_cremation() freed each cap_info's capbuf but kept capbufsize. The next input skipped the realloc and copied its first PES payload to a NULL buffer. Clear the pointer and reset the buffer sizes. Any two TS or PS inputs crashed with --videoedited; 0.96.5 segfaults the same way.
CCExtractor CI platform finished running the test files on linux. 171/238 tests matched the approved output:
67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10168, commit 94615d4:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10168), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
CCExtractor CI platform finished running the test files on windows. 171/238 tests matched the approved output:
67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10177, commit e708d72:
Fail there, pass here:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10177), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Repro instructions:
On master, both abort with
free(): double free detected in tcache 2. 0.96.5 (snap) segfaults on the first. Under ASan, passing the same TS file twice shows a second crash: a SEGV inmemmovefromcopy_payload_to_capbuf()(ts_functions.c:715).Problem
--videoeditedrunsgeneral_loop()once per input. The decoders and the demuxer'scap_infostreams are kept for the next input, but two pieces of per-file cleanup leave stale state behind:general_loop()freesdec_ctx->xds_ctxwithout clearing the pointer. The next input decodes 608 with the freed XDS context, then frees it a second time.cinfo_cremation()frees eachcap_info'scapbufbut keepscapbufsize(andcapbuflen). For the next input,copy_payload_to_capbuf()sees enough capacity, skips therealloc, and copies the first PES payload into a NULL buffer.The default mode (binary concat) calls both only once, at the very end, which is why it is unaffected.
Fix
free()→freep()forxds_ctx.rcwt_loop()already does this, for the same reason. The XDS functions return early on a NULL context.capbufsizeandcapbuflenafter freeingcapbuf.Verification
Repro (ASan): none of these crash any more:
01509e4d + c4dd893c,c4dd893c + 01509e4d,c4dd893c ×2,01509e4d ×2ab9cf8cf ×2,ab9cf8cf + 725a49f8The remaining leaks match a master single-file run (32 bytes) for the PS pairs. The TS pairs leak 96–112 bytes, in
copy_demuxer_from_rust_to_c()andinit_encoder().PS output:
ab9cf8cf + 725a49f8gives 33 cues (10 + 23). The text is identical to the two separate runs.Release sweep over 45 local samples (
.ts,.mpg,.vob,.wtv,.dvr-ms): all 81 output files are byte-identical to master.Default concat, without
--videoedited:01509e4d + c4dd893candab9cf8cf + 725a49f8are byte-identical to master.Formatting:
clang-formatis clean.Not fixed here
With the crashes gone,
--videoeditedoutput still has timing problems. These are separate defects, present wherever master didn't crash:ab9cf8cfcue 10 ends at 1:00.725 instead of 0:29.928. On TS the 608 screen also carries over, soc4dd893c ×2gives 3 cues instead of 2.fts_globalcorrectly advances by the first input's length (29929 ms). But the timing context keeps the first input's PTS state, so the second input's PTS restart is treated as a jump and also added tofts_offset.general_loop()formats, because the context is freed after the first.rcwt_loop()re-creates it;general_loop()doesn't.--out=reportwith MPEG-2 video also needs [FIX] Accept a NULL encoder in the MPEG-2 ES parser (report mode) #2502 in debug builds.