[PR #1707] [MERGED] fix: XDS segmentation faults #2424

Open
opened 2026-01-29 17:22:05 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1707
Author: @hrideshmg
Created: 6/28/2025
Status: Merged
Merged: 6/30/2025
Merged by: @cfsmp3

Base: masterHead: xds_segfault_fix


📝 Commits (2)

  • 716055c fix: XDS segmentation faults
  • a997e15 fix: memory leaks in unit tests for service decoder

📊 Changes

2 files changed (+60 additions, -39 deletions)

View changed files

📝 docs/CHANGES.TXT (+1 -0)
📝 src/rust/src/decoder/service_decoder.rs (+59 -39)

📄 Description

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

The regression tests under the XDS category have been failing on Windows due to segmentation faults for a while now. The cause for these errors stem from a small mistake that was made when the CEA-708 decoder functions were ported to Rust.

In specific, here is the offending line:

// Add symbol to window
window.rows[window.pen_row as usize] = Box::into_raw(Box::new(sym));

To contrast, here is the equivalent C section:

window->rows[window->pen_row][window->pen_column] = symbol;

window.rows has the following definition:

dtvcc_symbol *rows[15];
rows[i] = (dtvcc_symbol *)malloc(64 * sizeof(dtvcc_symbol));

As we can see, it is an array of pointers where each pointer points to a heap allocated row of dtvcc_symbols. In rust, this structure is incorrectly assumed to be an array of dtvcc_symbols. I've fixed this by using pointer arithmetic in rust to do the proper operation:

unsafe {
    let ptr: *mut dtvcc_symbol =
        window.rows[window.pen_row as usize].add(window.pen_column as usize);
    *ptr = sym;
}

The unit tests which directly utilize this operation were also leaking memory due to this, and thus I've made helper functions to properly handle those as well.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1707 **Author:** [@hrideshmg](https://github.com/hrideshmg) **Created:** 6/28/2025 **Status:** ✅ Merged **Merged:** 6/30/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `xds_segfault_fix` --- ### 📝 Commits (2) - [`716055c`](https://github.com/CCExtractor/ccextractor/commit/716055c0e29398848104932acad187d9b6406ea2) fix: XDS segmentation faults - [`a997e15`](https://github.com/CCExtractor/ccextractor/commit/a997e15bab6d7b20fd5cd55811a35234525d8be5) fix: memory leaks in unit tests for service decoder ### 📊 Changes **2 files changed** (+60 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `docs/CHANGES.TXT` (+1 -0) 📝 `src/rust/src/decoder/service_decoder.rs` (+59 -39) </details> ### 📄 Description <!-- Please prefix your pull request with one of the following: **[FEATURE]** **[FIX]** **[IMPROVEMENT]**. --> **In raising this pull request, I confirm the following (please check boxes):** - [x] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [x] I have checked that another pull request for this purpose does not exist. - [x] I have considered, and confirmed that this submission will be valuable to others. - [x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [x] I give this submission freely, and claim no ownership to its content. - [x] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).** **My familiarity with the project is as follows (check one):** - [ ] I have never used CCExtractor. - [ ] I have used CCExtractor just a couple of times. - [ ] I absolutely love CCExtractor, but have not contributed previously. - [x] I am an active contributor to CCExtractor. --- The regression tests under the XDS category have been failing on Windows due to segmentation faults for a while now. The cause for these errors stem from a small mistake that was made when the CEA-708 decoder functions were ported to Rust. In specific, here is the offending [line](https://github.com/hrideshmg/ccextractor/blob/54dfce4c89245f71b4ffc71e099e6298550a1cd5/src/rust/src/decoder/service_decoder.rs#L1139): ```Rust // Add symbol to window window.rows[window.pen_row as usize] = Box::into_raw(Box::new(sym)); ``` To contrast, here is the equivalent C [section](https://github.com/hrideshmg/ccextractor/blob/54dfce4c89245f71b4ffc71e099e6298550a1cd5/src/lib_ccx/ccx_decoders_708.c#L799): ```C window->rows[window->pen_row][window->pen_column] = symbol; ``` `window.rows` has the following definition: ```C dtvcc_symbol *rows[15]; rows[i] = (dtvcc_symbol *)malloc(64 * sizeof(dtvcc_symbol)); ``` As we can see, it is an array of pointers where each pointer points to a heap allocated row of `dtvcc_symbols`. In rust, this structure is incorrectly assumed to be an array of `dtvcc_symbols`. I've fixed this by using pointer arithmetic in rust to do the proper operation: ```Rust unsafe { let ptr: *mut dtvcc_symbol = window.rows[window.pen_row as usize].add(window.pen_column as usize); *ptr = sym; } ``` The unit tests which directly utilize this operation were also leaking memory due to this, and thus I've made helper functions to properly handle those as well. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:22:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2424