-
Notifications
You must be signed in to change notification settings - Fork 73
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
[Coverity] Fix coverity issues #2526
Conversation
📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2526. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/. |
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.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
num_observed++; | ||
if (num_observed == iteration.batch()) { | ||
notify_lock_guard.unlock(); |
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.
Why unlock here? It seems that num_observed
may experience synchronization error.
After this patch.
Thread 1 Thread 2
LINE 198 (after ++, num_observed=iteration-batch)
LINE 200
LINE 201
LINE 198 (after ++, num_observed = i-b + 1)
LINE 205
LINE 202
LINE 203 (num_objserved = 0)
LINE 205
Before this patch, it becomes num_observed = 1
You can miss num_observed counting after this commit.
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.
If markFilled() cannot affect num_observed or iteration.batch() and num_observed cannot affect markFilled(), you can do num_observed = 0;
before unlock.
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.
makes sense. how about adding a cv?
std::unique_lock notify_lock_guard(notify_mutex);
notify_emptied_num_obs_cv.wait(
notify_mutex, [this] { return num_observed != iteration.batch(); });
num_observed++;
if (num_observed == iteration.batch()) {
notify_lock_guard.unlock();
iq->markFilled(this);
notify_lock_guard.lock();
num_observed = 0;
notify_num_emptied_cv.notify_all();
}
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.
It's over-engineering. You don't need that much complexity. (is CV really required? can you do it only with mutex?)
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.
gotcha. Thank you for your guidance!
This PR resolves coverity issues of overflow, use of auto that causes a copy, missing lock and thread lock. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <dhyeon.jeong@samsung.com>
62b6c02
to
12c6fa0
Compare
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.
LGTM!
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.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
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.
LGTM
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.
LGTM
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.
LGTM
This PR resolves coverity issues of overflow, use of auto that causes a copy, missing lock and thread lock.
Self-evaluation: