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

wasm: add missing init reported by coverity #42897

Closed
wants to merge 1 commit into from

Conversation

mhdawson
Copy link
Member

Signed-off-by: Michael Dawson mdawson@devrus.com

Signed-off-by: Michael Dawson <mdawson@devrus.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 28, 2022
@mhdawson
Copy link
Member Author

Report from coverity:

26 private:
27  WasmStreamingObject(Environment* env, v8::Local<v8::Object> object)
28      : BaseObject(env, object) {
29    MakeWeak();
  	
CID 254660 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
2. uninit_member: Non-static class member wasm_size_ is not initialized in this constructor nor in any functions that it calls.
30  }
31
32  ~WasmStreamingObject() override {}
33
34 private:
35  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
36  static void SetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
37  static void Push(const v8::FunctionCallbackInfo<v8::Value>& args);
38  static void Finish(const v8::FunctionCallbackInfo<v8::Value>& args);
39  static void Abort(const v8::FunctionCallbackInfo<v8::Value>& args);
40
41  std::shared_ptr<v8::WasmStreaming> streaming_;
  	1. member_decl: Class member declaration for wasm_size_.
42  size_t wasm_size_;
43};

@tniessen
Copy link
Member

FWIW, this is where the initialization currently happens:

Local<Function> ctor = Initialize(env);
Local<Object> obj;
if (!ctor->NewInstance(env->context(), 0, nullptr).ToLocal(&obj)) {
return MaybeLocal<Object>();
}
CHECK(streaming);
WasmStreamingObject* ptr = Unwrap<WasmStreamingObject>(obj);
CHECK_NOT_NULL(ptr);
ptr->streaming_ = streaming;
ptr->wasm_size_ = 0;
return obj;

Other functions rely on the assumption that the initialization ran (e.g., will abort the process if streaming_ has not been initialized to a non-nullptr value).

Eventually, we might want to revisit how we initialize C++ backed JS objects in general.

@mhdawson mhdawson added the request-ci Add this label to start a Jenkins CI on a PR. label May 2, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 2, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

mhdawson added a commit that referenced this pull request May 10, 2022
Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #42897
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
@mhdawson
Copy link
Member Author

Landed in 7649989

@mhdawson mhdawson closed this May 10, 2022
BethGriggs pushed a commit that referenced this pull request May 16, 2022
Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #42897
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
@RafaelGSS RafaelGSS mentioned this pull request May 16, 2022
@juanarbol
Copy link
Member

Backport refs: #42701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants