Skip to content
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

inspector: fix Coverity defects #12272

Merged
merged 0 commits into from Apr 11, 2017

Conversation

@eugeneo
Copy link
Contributor

commented Apr 7, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

inspector: minor fixes

src/inspector_io.cc Outdated
@@ -236,6 +236,7 @@ void InspectorIo::WriteCbIO(uv_async_t* async) {
template<typename Transport>
void InspectorIo::WorkerRunIO() {
uv_loop_t loop;
loop.data = nullptr;

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu Apr 7, 2017

Member

According to libuv docs, this should be initialized in the next line with uv_loop_init():

void* uv_loop_t.data
Space for user-defined arbitrary data. libuv does not use this field. libuv does, however, initialize it to NULL in uv_loop_init(), and it poisons the value (on debug builds) on uv_loop_close().

This comment has been minimized.

Copy link
@eugeneo

eugeneo Apr 7, 2017

Author Contributor

I don't think Coverity is aware of the fact...

CID 166789 (# 1 of 1): Uninitialized pointer read (UNINIT)
2. uninit_use_in_call: Using uninitialized value loop.data when calling uv_loop_init."

This comment has been minimized.

Copy link
@addaleax

addaleax Apr 9, 2017

Member

Unless I’m missing something obvious, the libuv docs are lying:

saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
loop->data = saved_data;

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 11, 2017

Member

But not for long: libuv/libuv#1299

Alternative syntax: uv_loop_t loop = uv_loop_t() (or auto loop = uv_loop_t() if you don't like to repeat yourself), that zeroes out all fields.

@mscdex mscdex added the inspector label Apr 7, 2017

@eugeneo

This comment has been minimized.

Copy link
Contributor Author

commented Apr 7, 2017

src/inspector_io.cc Outdated
@@ -236,6 +236,7 @@ void InspectorIo::WriteCbIO(uv_async_t* async) {
template<typename Transport>
void InspectorIo::WorkerRunIO() {
uv_loop_t loop;
loop.data = nullptr;

This comment has been minimized.

Copy link
@addaleax

addaleax Apr 9, 2017

Member

Unless I’m missing something obvious, the libuv docs are lying:

saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
loop->data = saved_data;

src/inspector_io.cc Outdated
@@ -236,6 +236,7 @@ void InspectorIo::WriteCbIO(uv_async_t* async) {
template<typename Transport>
void InspectorIo::WorkerRunIO() {
uv_loop_t loop;
loop.data = nullptr;

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 11, 2017

Member

But not for long: libuv/libuv#1299

Alternative syntax: uv_loop_t loop = uv_loop_t() (or auto loop = uv_loop_t() if you don't like to repeat yourself), that zeroes out all fields.

src/inspector_io.cc Outdated
if (0 == uv_fs_realpath(&loop, &req, script_name_.c_str(), nullptr))
req.ptr = nullptr;
err = uv_fs_realpath(&loop, &req, script_name_.c_str(), nullptr);
if (0 == err && req.ptr != nullptr)

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 11, 2017

Member

The nullptr check shouldn't be necessary but perhaps coverity isn't smart enough to figure that out... I'd turn it into a CHECK_NE(req.ptr, nullptr).

This comment has been minimized.

Copy link
@eugeneo

eugeneo Apr 11, 2017

Author Contributor

Done.

@bnoordhuis
Copy link
Member

left a comment

LGTM sans comment.

src/inspector_io.cc Outdated
if (0 == uv_fs_realpath(&loop, &req, script_name_.c_str(), nullptr))
req.ptr = nullptr;
err = uv_fs_realpath(&loop, &req, script_name_.c_str(), nullptr);
if (0 == err) {

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 11, 2017

Member

You don't need to assign to err anymore, that would keep the diff smaller.

@eugeneo

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2017

@eugeneo eugeneo closed this Apr 11, 2017

@eugeneo eugeneo deleted the eugeneo:signal-coverity branch Apr 11, 2017

@eugeneo eugeneo merged commit 42be835 into nodejs:master Apr 11, 2017

@eugeneo

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2017

Landed as 42be835

@jasnell jasnell referenced this pull request May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.