Skip to content

Coverity- Critical and High priority issue fixes#498

Open
trupthi1403 wants to merge 2 commits into
masterfrom
feature/RDKEMW-17768
Open

Coverity- Critical and High priority issue fixes#498
trupthi1403 wants to merge 2 commits into
masterfrom
feature/RDKEMW-17768

Conversation

@trupthi1403
Copy link
Copy Markdown

Summary: Fix for lock, missing_lock, uninitialized fields, uncaught exception, out-of-bounds and Pointer to local outside scope
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-17768

Summary: Fix for out-of-bounds and Pointer to local outside scope issues
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-17891
Copilot AI review requested due to automatic review settings May 12, 2026 07:35
@github-actions
Copy link
Copy Markdown

Pull request must be merged with a description containing the required fields,

Summary:
Type: Feature/Fix/Cleanup
Test Plan:
Jira:

If there is no jira releated to this change, please put 'Jira: NO-JIRA'.

Description can be changed by editing the top comment on your pull request and making a new commit.

Copy link
Copy Markdown
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.

Pull request overview

This PR targets a set of Coverity-reported issues across the server manager, media pipeline (client/server), GStreamer player, and IPC layers—primarily around locking, initialization, and exception-safety.

Changes:

  • Adds/adjusts locking to address potential data races (e.g., ActiveRequests map access, GstSrc finalizer).
  • Initializes previously-uninitialized members/fields (e.g., NeedMediaData, MediaPipeline, GstDecryptor).
  • Refactors IPC code to reduce lock lifetimes / improve analyzer clarity, and adds destructor exception handling.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
serverManager/service/source/ServerManagerService.cpp Updates startup log message text.
media/server/main/source/NeedMediaData.cpp Initializes m_maxMediaBytes to avoid uninitialized use.
media/server/main/source/ActiveRequests.cpp Adds mutex locking around request map access in addSegment() / getSegments().
media/server/gstplayer/source/GstSrc.cpp Adds object lock during URI free in finalize.
media/server/gstplayer/source/GstGenericPlayer.cpp Wraps destructor cleanup calls in try/catch.
media/server/gstplayer/source/GstDecryptor.cpp Initializes decryption service pointer.
media/client/main/source/MediaPipeline.cpp Initializes m_attachingSource; adjusts flush locking/flow.
media/client/ipc/source/IpcModule.cpp Splits weak/shared channel acquisition for analyzer clarity.
ipc/server/source/IpcServerImpl.cpp Narrows lock scope by copying required state out under lock.
ipc/common/source/NamedSocket.cpp Adjusts sysconf handling to avoid unsigned conversion pitfalls.
ipc/client/source/IpcChannelImpl.cpp Refactors locking in error handling and CallMethod send path.
common/source/LinuxUtils.cpp Adjusts sysconf handling to avoid unsigned conversion pitfalls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread serverManager/service/source/ServerManagerService.cpp Outdated
Comment thread ipc/client/source/IpcChannelImpl.cpp
Comment thread media/server/gstplayer/source/GstGenericPlayer.cpp
Comment thread ipc/common/source/NamedSocket.cpp Outdated
Comment thread common/source/LinuxUtils.cpp Outdated
@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
WARNING: Lines coverage decreased from: 84.3% to 84.2%
Functions coverage stays unchanged and is: 92.6%

@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from f553263 to 93aa006 Compare May 12, 2026 10:16
@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
WARNING: Lines coverage decreased from: 84.3% to 84.2%
Functions coverage stays unchanged and is: 92.6%

@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from 93aa006 to 627a5b0 Compare May 12, 2026 15:35
Copilot AI review requested due to automatic review settings May 12, 2026 15:35
Copy link
Copy Markdown
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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

media/server/main/source/ActiveRequests.cpp:136

  • getSegments() takes the mutex but returns a reference to data owned by m_requestMap. Once the function returns the lock is released, so another thread can erase()/clear() and invalidate the returned reference, leading to use-after-free/data races. Consider changing the API to return a copy (by value) or moving/extracting the segments under the lock (e.g., an extractSegments()/consumeSegments() that returns/moves the vector and removes the request) so callers never hold a dangling reference.
const IMediaPipeline::MediaSegmentVector &ActiveRequests::getSegments(std::uint32_t requestId) const
{
    std::unique_lock<std::mutex> lock{m_mutex};
    auto requestIter{m_requestMap.find(requestId)};
    if (requestIter != m_requestMap.end())
    {
        return requestIter->second.getSegments();
    }

Comment thread ipc/client/source/IpcChannelImpl.cpp Outdated
Comment thread ipc/server/source/IpcServerImpl.cpp
Comment thread ipc/server/source/IpcServerImpl.cpp Outdated
Comment thread ipc/common/source/NamedSocket.cpp
Comment thread common/source/LinuxUtils.cpp
@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from 627a5b0 to 5b4bcf5 Compare May 13, 2026 06:25
Copilot AI review requested due to automatic review settings May 13, 2026 07:29
@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from 5b4bcf5 to b6dcdce Compare May 13, 2026 07:29
Copy link
Copy Markdown
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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

media/server/main/source/ActiveRequests.cpp:136

  • getSegments() now takes m_mutex only for the map lookup, but returns a const & to ActiveRequestsData::m_segments and releases the lock immediately when the function returns. Callers can then iterate that vector while other threads call addSegment()/erase()/clear() under the same mutex, which is a data race and can lead to use-after-free/reallocation. To make this thread-safe, return a value/copy (snapshot) of the segment vector (or another owned container), or provide an API that performs the consumer operation while holding the lock (e.g., callback-based access).
const IMediaPipeline::MediaSegmentVector &ActiveRequests::getSegments(std::uint32_t requestId) const
{
    std::unique_lock<std::mutex> lock{m_mutex};
    auto requestIter{m_requestMap.find(requestId)};
    if (requestIter != m_requestMap.end())
    {
        return requestIter->second.getSegments();
    }

@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from b6dcdce to 0534e10 Compare May 13, 2026 11:54
Copilot AI review requested due to automatic review settings May 13, 2026 12:44
@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from 0534e10 to b4cd8aa Compare May 13, 2026 12:44
Copy link
Copy Markdown
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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (3)

media/server/main/source/ActiveRequests.cpp:135

  • getSegments() now takes m_mutex, but it returns a const reference to internal storage and releases the lock before the caller can iterate the vector. That means callers can still observe concurrent mutation (or invalidation on erase) without protection. To make the locking meaningful, return a copy/snapshot of the segments (copy under the lock) or change the API to execute a caller-supplied callback while holding the lock.
    std::unique_lock<std::mutex> lock{m_mutex};
    auto requestIter{m_requestMap.find(requestId)};
    if (requestIter != m_requestMap.end())
    {
        return requestIter->second.getSegments();

ipc/common/source/NamedSocket.cpp:301

  • Same sysconf handling issue as getSocketOwnerId(): sysconf(_SC_GETGR_R_SIZE_MAX) can legally return -1 with errno unchanged (indeterminate limit). Consider checking errno and using a fallback buffer size / ERANGE-retry strategy so group lookup still works in that case.
    // sysconf returns long; -1 on error. Store as int64_t to avoid unsigned conversion issues.
    const int64_t bufferSizeLong = sysconf(_SC_GETGR_R_SIZE_MAX);
    if (!socketGroup.empty() && bufferSizeLong > 0)
    {
        const size_t kBufferSize = static_cast<size_t>(bufferSizeLong);

common/source/LinuxUtils.cpp:65

  • sysconf(_SC_GETGR_R_SIZE_MAX) may return -1 with errno unchanged to indicate an indeterminate limit. The current check (bufferSizeLong > 0) will skip group lookup in that case. Consider checking errno and using a fallback buffer size (and/or retrying on ERANGE) so ownership changes still work when sysconf doesn't provide a limit.
    // sysconf returns long; -1 on error. Store as int64_t to avoid unsigned conversion issues.
    const int64_t bufferSizeLong = sysconf(_SC_GETGR_R_SIZE_MAX);
    if (!fileGroup.empty() && bufferSizeLong > 0)
    {
        const size_t kBufferSize = static_cast<size_t>(bufferSizeLong);

Comment thread ipc/client/source/IpcChannelImpl.cpp
Comment thread ipc/common/source/NamedSocket.cpp
Comment thread common/source/LinuxUtils.cpp
Summary: Fix for lock, missing_lock, uninitialized fields and uncaught
exception
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-17892
@trupthi1403 trupthi1403 force-pushed the feature/RDKEMW-17768 branch from b4cd8aa to 56b4534 Compare May 13, 2026 19:35
@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
WARNING: Lines coverage decreased from: 84.3% to 84.2%
Functions coverage stays unchanged and is: 92.6%

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