Skip to content

Fixing CID:430751[do not merge]#117

Closed
Sid2001-maker wants to merge 2 commits into
developfrom
temp/RDKEMW-12252
Closed

Fixing CID:430751[do not merge]#117
Sid2001-maker wants to merge 2 commits into
developfrom
temp/RDKEMW-12252

Conversation

@Sid2001-maker

Copy link
Copy Markdown
Contributor

fixing medium level coverity issue CID:430751

Sid2001-maker and others added 2 commits February 3, 2026 18:44
…tical and High issues

Reason for change: Resolve Critical and high level issues in coverity
Test Procedure: build should be successful
Risk: low
Priority: P2
@Sid2001-maker Sid2001-maker requested a review from a team as a code owner February 9, 2026 06:43
Copilot AI review requested due to automatic review settings February 9, 2026 06:43
@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (Sid2001-maker)[https://github.com/Sid2001-maker]
@sid-TEL
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@Sid2001-maker Sid2001-maker changed the title Temp/rdkemw 12252 Fixing CID:430751[do not merge] Feb 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a medium-severity Coverity finding (CID:430751) by addressing several initialization, locking, and error-handling issues across the JS runtime executable, client/server utilities, and JSC integration.

Changes:

  • Adds safer control flow/error handling (try/catch in main, safer waits with predicates, safer JSON parsing default init).
  • Fixes synchronization correctness (proper mutex scoping in dispatchPending, atomic application ID generation, dev-console queue handling).
  • Improves robustness of external I/O setup (validates --display, checks curl_easy_setopt return codes, adds file/stat/read checks, avoids some null dereferences).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/jsruntime.cpp Wraps main with exception handling; validates --display argument before passing to renderer.
src/jsc/jsc_lib/jsc_lib.cpp Fixes uncaught exception logging string conversion; checks curl_easy_setopt return codes; safer trailing-slash check.
src/jsc/JavaScriptUtils.cpp Fixes incorrect mutex usage in dispatchPending; adds Coverity annotations; hardens file read + adds cleanup in early returns.
src/jsc/JavaScriptEngine.cpp Fixes log format specifier for GC interval.
src/jsc/JavaScriptContext.cpp Frees mNetworkMetricsData in destructor; null-checks gAAMPJSBindings before use.
src/NativeJSRenderer.cpp Makes application ID generation thread-safe; improves locking assumptions; reduces race window in dev-console queue processing; checks curl option setting.
src/JSRuntimeServer.cpp Initializes JsonWrap::getUint32 local to avoid uninitialized use.
src/JSRuntimeClientContainer.cpp Wraps main with exception handling; normalizes log newline.
src/JSRuntimeClient.cpp Uses predicate wait to avoid spurious wakeups; wraps main with exception handling.
include/JSRuntimeClient.h Adds response-received flag + predicate wait to avoid spurious wakeups.
include/IJavaScriptContext.h Adds virtual destructor for interface safety.

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

Comment thread include/JSRuntimeClient.h
Comment on lines 45 to 60
bool sendCommand(std::string command, std::string &response)
{
Derived &derived = static_cast<Derived &>(*this);
if (derived.send(command))
{
std::unique_lock<std::mutex> lock(mResponseMutex);
mResponseCondition.wait_for(lock, std::chrono::seconds(5));
response = mLastResponse;
return true;
mResponseReceived = false;
bool gotResponse = mResponseCondition.wait_for(lock, std::chrono::seconds(5),
[this]() { return mResponseReceived; });

if (gotResponse)
{
response = mLastResponse;
return true;
}
}

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

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

Race condition: sendCommand() resets mResponseReceived after derived.send() returns. If onMessage() runs between send() and acquiring mResponseMutex, it can set mResponseReceived=true and notify, then sendCommand() overwrites it back to false and waits until timeout. Reset the flag (and ideally clear/track the response) before sending, or use a monotonically increasing request/response sequence number so early responses aren’t lost.

Copilot uses AI. Check for mistakes.
@Sid2001-maker Sid2001-maker deleted the temp/RDKEMW-12252 branch February 9, 2026 07:37
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants