Skip to content

Conversation

@sirknightj
Copy link
Contributor

Issue #, if available:

  • N/A

What was changed?

  • Fixed segmentation fault in JNI layer caused by dereferencing garbage pointer from failed ::kinesisVideoStreamGetStreamInfo() calls
  • Added stream handle validation before frame operations
  • Added integration tests for invalid stream state scenarios

Why was it changed?

  • kinesisVideoStreamGetStreamInfo() returns an error when the stream is already freed, leaving pStreamInfo as a garbage value
  • The code was unconditionally dereferencing this garbage pointer, which may cause a segmentation fault depending on what value is there. A core dump analysis identified this specific line as the crash source.
  • Some validation exists to prevent frame operations on invalid/freed stream handles in the NativeKinesisVideoProducerStream.putFrame(), these changes add more checks.

How was it changed?

  • Added status checking for kinesisVideoStreamGetStreamInfo() return value and proper exception throwing before pointer dereference
  • Added precondition validation in putFrame() to ensure stream handle exists in the handle map
  • Created PutFrameAtInvalidStatesIntegTest with various test scenarios covering frame submission after stream stop/free operations, and garbage stream handles

What testing was done for the changes?

  • Ran the new tests locally
  • Ran the DemoAppMain locally

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.06%. Comparing base (4593758) to head (4eaa5fd).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #247      +/-   ##
=============================================
+ Coverage      49.83%   50.06%   +0.22%     
- Complexity       585      589       +4     
=============================================
  Files            106      106              
  Lines           4154     4155       +1     
  Branches         268      268              
=============================================
+ Hits            2070     2080      +10     
+ Misses          1936     1929       -7     
+ Partials         148      146       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@unicornss unicornss requested a review from Ahhorse1 August 14, 2025 22:02
@sirknightj sirknightj merged commit c2a66c9 into develop Oct 20, 2025
47 of 49 checks passed
@sirknightj sirknightj deleted the putFrame-safety branch October 20, 2025 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants