src: fix some recently introduced coverity issues#47240
Closed
mhdawson wants to merge 3 commits intonodejs:mainfrom
Closed
src: fix some recently introduced coverity issues#47240mhdawson wants to merge 3 commits intonodejs:mainfrom
mhdawson wants to merge 3 commits intonodejs:mainfrom
Conversation
Signed-off-by: Michael Dawson <mdawson@devrus.com>
richardlau
approved these changes
Mar 23, 2023
Member
Author
|
Coverity reports src/dataqueue/queue.cc
public:
788 static std::unique_ptr<FdEntry> Create(Environment* env, Local<Value> path) {
789 // We're only going to create the FdEntry if the file exists.
1. var_decl: Declaring variable req without initializer.
790 uv_fs_t req;
791 auto cleanup = OnScopeLeave([&] { uv_fs_req_cleanup(&req); });
792
793 auto buf = std::make_shared<BufferValue>(env->isolate(), path);
2. Condition uv_fs_stat(NULL, &req, buf->out(), NULL) < 0, taking false branch.
794 if (uv_fs_stat(nullptr, &req, buf->out(), nullptr) < 0) return nullptr;
795
CID 310020 (#1 of 1): Uninitialized scalar variable (UNINIT)
3. uninit_use_in_call: Using uninitialized value req.statbuf when calling make_unique.
796 return std::make_unique<FdEntry>(
797 env, std::move(buf), req.statbuf, 0, req.statbuf.st_size);
798 }
static bool CheckModified(FdEntry* entry, int fd) {
1. var_decl: Declaring variable req without initializer.
852 uv_fs_t req;
853 auto cleanup = OnScopeLeave([&] { uv_fs_req_cleanup(&req); });
854 // TODO(jasnell): Note the use of a sync fs call here is a bit unfortunate.
855 // Doing this asynchronously creates a bit of a race condition tho, a file
856 // could be unmodified when we call the operation but then by the time the
857 // async callback is triggered to give us that answer the file is modified.
858 // While such silliness is still possible here, the sync call at least makes
859 // it less likely to hit the race.
2. Condition uv_fs_fstat(NULL, &req, fd, NULL) < 0, taking false branch.
860 if (uv_fs_fstat(nullptr, &req, fd, nullptr) < 0) return true;
3. uninit_use_in_call: Using uninitialized value req.statbuf.st_size when calling is_modified. [[show details](https://scan9.scan.coverity.com/eventId=9011842-3&modelId=9011842-0&fileInstanceId=111313726&filePath=%2Fsrc%2Fdataqueue%2Fqueue.cc&fileStart=846&fileEnd=849)]
CID 310018 (#1-2 of 2): Uninitialized scalar variable (UNINIT)
4. uninit_use_in_call: Using uninitialized value req.statbuf.st_mtim.tv_nsec when calling is_modified. [[show details](https://scan9.scan.coverity.com/eventId=9011842-6&modelId=9011842-1&fileInstanceId=111313726&filePath=%2Fsrc%2Fdataqueue%2Fqueue.cc&fileStart=846&fileEnd=849)]
861 return entry->is_modified(req.statbuf);
862 }
test/embedding/embedtest.cc
} else {
5. var_decl: Declaring variable req without initializer.
78 uv_fs_t req;
79 int statret = uv_fs_stat(nullptr, &req, filename, nullptr);
6. Condition statret == 0, taking true branch.
80 assert(statret == 0);
CID 307777 (#1 of 1): Uninitialized scalar variable (UNINIT)
7. uninit_use: Using uninitialized value req.statbuf.st_size.
81 size_t filesize = req.statbuf.st_size;
82 uv_fs_req_cleanup(&req);
83
84 std::vector<char> vec(filesize);
85 size_t read = fread(vec.data(), filesize, 1, fp);
86 assert(read == 1);
87 snapshot = node::EmbedderSnapshotData::FromBlob(vec);
88 } |
Member
Author
|
Not sure why it would have failed for coverage and not for my local make test linux run, will have to look at it tomorrow. |
Signed-off-by: Michael Dawson <mdawson@devrus.com>
Member
My guess would be either compiler level and/or the |
Signed-off-by: Michael Dawson <mdawson@devrus.com>
Member
Author
|
Updated to initialize in another way, lets see if the compilers are happy with it across platforms. Also compiled ok locally. |
Member
Author
|
Requesting ci to check across all platforms |
Collaborator
Collaborator
Collaborator
lpinca
approved these changes
Mar 25, 2023
Collaborator
Collaborator
Member
Author
|
Landed in fe449a2 |
mhdawson
added a commit
that referenced
this pull request
Mar 28, 2023
Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #47240 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
18 tasks
RafaelGSS
pushed a commit
that referenced
this pull request
Apr 5, 2023
Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #47240 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Merged
RafaelGSS
pushed a commit
that referenced
this pull request
Apr 6, 2023
Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #47240 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
RafaelGSS
pushed a commit
that referenced
this pull request
Apr 7, 2023
Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #47240 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.