-
Notifications
You must be signed in to change notification settings - Fork 0
Fix High and Medium Level issues #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
be8f662
RDKEMW-12252: Coverity Scan Report - Analyzing and Fixing all the Cri…
Sid2001-maker 8939632
Update src/jsruntime.cpp
vjain008 7f12965
Update src/jsruntime.cpp
Sid2001-maker c744166
Update src/jsc/jsc_lib/jsc_lib.cpp
Sid2001-maker 4de5f6f
Fixing the Coverity Issue CID:430751
sid-TEL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||
| #include <string.h> | ||||||
| #include <vector> | ||||||
| #include <thread> | ||||||
| #include <atomic> | ||||||
| #include <signal.h> | ||||||
| #ifndef __APPLE__ | ||||||
| #include <linux/input.h> | ||||||
|
|
@@ -225,10 +226,8 @@ void NativeJSRenderer::setEnvForConsoleMode(ModuleSettings& moduleSettings) | |||||
|
|
||||||
| uint32_t NativeJSRenderer::createApplicationIdentifier() | ||||||
| { | ||||||
| static uint32_t id = 1; | ||||||
| uint32_t ret = id; | ||||||
| id++; | ||||||
| return ret; | ||||||
| static std::atomic<uint32_t> id{1}; | ||||||
| return id++; | ||||||
| } | ||||||
|
|
||||||
| uint32_t NativeJSRenderer::createApplication(ModuleSettings& moduleSettings, std::string userAgent) | ||||||
|
|
@@ -292,6 +291,7 @@ bool NativeJSRenderer::terminateApplication(uint32_t id) | |||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||
| void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | ||||||
| { | ||||||
| double startTime = getTimeInMilliSec(); | ||||||
|
|
@@ -330,9 +330,9 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | |||||
| context->setCreateApplicationEndTime(endTime, id); | ||||||
|
|
||||||
| mContextMap[id].context=context; | ||||||
| mUserMutex.unlock(); | ||||||
| } | ||||||
|
|
||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||
| void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | ||||||
| { | ||||||
| uint32_t id = appRequest.mId; | ||||||
|
|
@@ -365,7 +365,7 @@ void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | |||||
| NativeJSLogger::log(INFO, "Adding the window location: %s to js file\n", window.str().c_str()); | ||||||
| context->runScript(window.str().c_str(),true, url, nullptr, true); | ||||||
| } | ||||||
| NativeJSLogger::log(INFO, "nativeJS application thunder execution url: %s, result: %d\n", url.c_str(), ret ? 1 : 0); | ||||||
| NativeJSLogger::log(INFO, "nativeJS application thunder execution url: %s\n", url.c_str()); | ||||||
| ret = context->runScript(chunk.contentsBuffer, true, url, nullptr, true); | ||||||
| NativeJSLogger::log(INFO, "nativeJS application execution result: %d\n", ret ? 1 : 0); | ||||||
| double duration = context->getExecutionDuration(); | ||||||
|
|
@@ -398,6 +398,7 @@ void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||
| void NativeJSRenderer::runJavaScriptInternal(ApplicationRequest& appRequest) | ||||||
| { | ||||||
| uint32_t id = appRequest.mId; | ||||||
|
|
@@ -427,6 +428,7 @@ void NativeJSRenderer::runJavaScriptInternal(ApplicationRequest& appRequest) | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||
| void NativeJSRenderer::terminateApplicationInternal(ApplicationRequest& AppRequest) | ||||||
| { | ||||||
| uint32_t id = AppRequest.mId; | ||||||
|
|
@@ -445,7 +447,7 @@ void NativeJSRenderer::terminateApplicationInternal(ApplicationRequest& AppReque | |||||
|
|
||||||
| else | ||||||
| { | ||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url); | ||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d\n", id); | ||||||
| return ; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -468,11 +470,10 @@ void NativeJSRenderer::run() | |||||
| { | ||||||
| while(mRunning) | ||||||
| { | ||||||
| uint32_t id; | ||||||
| mUserMutex.lock(); | ||||||
| if (mConsoleMode) { | ||||||
| processDevConsoleRequests(); | ||||||
| } | ||||||
| mUserMutex.lock(); | ||||||
| for (int i=0; i<gPendingRequests.size(); i++) | ||||||
| { | ||||||
|
|
||||||
|
|
@@ -506,10 +507,13 @@ void NativeJSRenderer::run() | |||||
| if(!mTestFileName.empty()) | ||||||
| { | ||||||
| ModuleSettings settings; | ||||||
| uint32_t id = createApplicationIdentifier(); | ||||||
| settings.enableJSDOM = mEnableTestFileDOMSupport; | ||||||
| ApplicationRequest appRequest(id, RUN, mTestFileName, settings.enableHttp, settings.enableXHR, settings.enableWebSocket, settings.enableWebSocketEnhanced, settings.enableFetch, settings.enableJSDOM, settings.enableWindow, settings.enablePlayer); | ||||||
| mUserMutex.lock(); | ||||||
| NativeJSRenderer::createApplicationInternal(appRequest); | ||||||
| NativeJSRenderer::runApplicationInternal(appRequest); | ||||||
| mUserMutex.unlock(); | ||||||
| mTestFileName = ""; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -531,27 +535,30 @@ void NativeJSRenderer::run() | |||||
|
|
||||||
| void NativeJSRenderer::processDevConsoleRequests() | ||||||
| { | ||||||
| std::deque<std::string> localQueue; | ||||||
|
|
||||||
| // Move items from shared queue to local queue while holding the lock | ||||||
| mConsoleState->inputMutex.lock(); | ||||||
|
|
||||||
| if (mConsoleState->codeToExecute.empty()) { | ||||||
| mConsoleState->inputMutex.unlock(); | ||||||
| return; | ||||||
| } | ||||||
| localQueue.swap(mConsoleState->codeToExecute); | ||||||
| mConsoleState->inputMutex.unlock(); | ||||||
|
|
||||||
| std::lock_guard<std::mutex> lockg(mConsoleState->isProcessing_cv_m); | ||||||
| bool dataProcessed = false; | ||||||
|
|
||||||
| for (; !mConsoleState->codeToExecute.empty(); mConsoleState->codeToExecute.pop_front()) { | ||||||
| bool ret = mConsoleState->consoleContext->runScript(mConsoleState->codeToExecute.front().c_str(), false); | ||||||
| // Process items from local queue (no race condition) | ||||||
| for (const auto& code : localQueue) { | ||||||
| bool ret = mConsoleState->consoleContext->runScript(code.c_str(), false); | ||||||
|
||||||
| bool ret = mConsoleState->consoleContext->runScript(code.c_str(), false); | |
| mConsoleState->consoleContext->runScript(code.c_str(), false); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CommandInterface::sendCommand(),
derived.send(command)happens beforemResponseReceivedis reset undermResponseMutex. If a response arrives quickly,onMessage()can setmResponseReceived=trueand notify beforesendCommand()takes the lock, and thensendCommand()overwrites the flag back to false and waits the full timeout (missed wakeup). Reset the flag (or increment a sequence counter) while holdingmResponseMutexbefore sending, and consider clearing/consumingmLastResponsein the same critical section.