Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Fix null pointer dereference in FindServerUTCTime tests

Issue

The new UTC sync throttling tests were crashing with null pointer dereference when calling FindServerUTCTime directly.

Root Cause

The FindServerUTCTime implementation calls mMPDParseHelper->SetLocalTimeDelta(mDeltaTime) at the end, but mMPDParseHelper is initialized to NULL in the constructor and only gets set during full MPD initialization via GetMPDParseHelper().

When unit tests call FindServerUTCTime directly with just an XML node (bypassing InitializeMPD), the helper remains null, causing a crash.

Fix

Added defensive null check before calling SetLocalTimeDelta:

if (mMPDParseHelper)
{
    mMPDParseHelper->SetLocalTimeDelta(mDeltaTime);
}

This makes the function more robust and allows it to be tested in isolation without requiring full MPD setup.

Changes

  • fragmentcollector_mpd.cpp: Added null check for mMPDParseHelper
  • FunctionalTests.cpp: Removed GTEST_SKIP() from all 5 tests to enable them

All tests now run successfully without crashes.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Anurag Krishnan and others added 14 commits January 14, 2026 20:32
Reason for change: Updates UTCTiming logic to skip sync if interval hasn’t elapsed. Add Configs to control the interval
Test Procedure: updated in ticket
Risks: Low

Signed-off-by: Anurag Krishnan <akrish513@cable.comcast.com>
deprecated eAAMPConfig_UTCSyncOnErrorRetrySec
fixed bug with config order causing runtime crash
added some doxygen comments

Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Merge branch 'feature/VPLAY-12359_UTCTiming' of https://github.com/rdkcentral/aamp into feature/VPLAY-12359_UTCTiming

Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Extended FindServerUTCTime test coverage with 5 new test cases:
1. SyncOnStartup - Verify initial sync when UTCSyncOnStartup enabled
2. SkipSyncBeforeInterval - Verify sync skipped when interval not elapsed
3. SyncAfterInterval - Verify sync occurs when interval has elapsed
4. UseCachedOffset - Verify cached offset used when sync skipped
5. NoSyncWhenStartupDisabled - Verify no sync when startup disabled

These tests verify the interval-based throttling behavior including:
- Network sync calls only when appropriate
- Cached offset usage between sync intervals
- Proper time progression and interval checking
- Configuration setting behavior

Addresses PR feedback on #853 for comprehensive UTC sync testing.

Co-authored-by: pstroffolino <20442081+pstroffolino@users.noreply.github.com>
Copilot AI changed the title [WIP] Add changes to address feedback on VPLAY-12359 Add interval-based throttling tests for FindServerUTCTime Jan 15, 2026
Copilot AI requested a review from pstroffolino January 15, 2026 02:49
@pstroffolino
Copy link
Contributor

@copilot this new tests crash with null pointer deference

@pstroffolino
Copy link
Contributor

@copilot I marked them with GTEST_SKIP() temporarily.

@pstroffolino pstroffolino marked this pull request as ready for review January 15, 2026 03:34
Copilot AI review requested due to automatic review settings January 15, 2026 03:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Added null check for mMPDParseHelper before calling SetLocalTimeDelta
to prevent crashes when the helper is not initialized. This makes the
function more defensive and allows unit tests to call FindServerUTCTime
directly without requiring full MPD initialization.

Removed GTEST_SKIP() from all 5 UTC sync tests:
- FindServerUTCTime_SyncOnStartup
- FindServerUTCTime_SkipSyncBeforeInterval
- FindServerUTCTime_SyncAfterInterval
- FindServerUTCTime_UseCachedOffset
- FindServerUTCTime_NoSyncWhenStartupDisabled

Tests now run successfully with the null check in place.

Co-authored-by: pstroffolino <20442081+pstroffolino@users.noreply.github.com>
Copilot AI requested a review from a team as a code owner January 15, 2026 03:39
Copy link
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot this new tests crash with null pointer deference

Fixed in commit be0bbf7. The crash was caused by FindServerUTCTime calling mMPDParseHelper->SetLocalTimeDelta() when mMPDParseHelper was null.

Added a null check before the call to make the function defensive. All 5 tests now run without crashes.

Base automatically changed from feature/VPLAY-12359_UTCTiming to dev_sprint_25_2 January 15, 2026 03:59
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.

2 participants