Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-01-21src: reduce includes of node_internals.hJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/25507 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-18src: schedule destroy hooks in BeforeExit early during bootstrapJoyee Cheung
Instead of doing it in the `internalBinding('async_wrap')` initialization whose first call is uncertain depending on how the native modules are loaded in JS land during bootstrap. PR-URL: https://github.com/nodejs/node/pull/25020 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-12-04src: fix type mismatch warnings from missing privSam Roberts
Registration initialization functions are expected to have a 4th argument, a void*, so add them where necessary to fix the warnings. PR-URL: https://github.com/nodejs/node/pull/24737 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-12-03src: use custom TryCatch subclassGus Caplan
PR-URL: https://github.com/nodejs/node/pull/24751 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-12-01src: elevate v8 namespaces referencedJuan José Arboleda
PR-URL: https://github.com/nodejs/node/pull/24657 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2018-11-13async_hooks: add HandleScopes to C++ embedder/addon APIAnna Henningsen
Add `HandleScope`s to the public C++ API for embedders/addons, since these methods create V8 handles that should not leak into the outer scopes. In particular, for some of the methods it was not clear from the function signatures that these functions previously needed to be invoked with a `HandleScope`. PR-URL: https://github.com/nodejs/node/pull/24285 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-11-13src: bundle persistent-to-local methods as classGabriel Schulhof
Create a class `PersistentToLocal` which contains three methods, `Strong`, `Weak`, and `Default`: * `Strong` returns a `Local` from a strong persistent reference, * `Weak` returns a `Local` from a weak persistent reference, and * `Default` decides based on `IsWeak()` which of the above two to call. These replace `node::StrongPersistentToLocal()`, `node::WeakPersistentToLocal()`, and `node::PersistentToLocal()`, respectively. PR-URL: https://github.com/nodejs/node/pull/24276 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-07src: fix Get() usage in async_wrap.cccjihrig
PR-URL: https://github.com/nodejs/node/pull/24060 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-11-06src: move error handling code into node_errors.ccJoyee Cheung
Move the following code into a new node_errors.cc file and declare them in node_errors.h for clarity and make it possible to include them with node_errors.h. - AppendExceptionLine() - DecorateErrorStack() - FatalError() - OnFatalError() - PrintErrorString() - FatalException() - ReportException() - FatalTryCatch And move the following definitions (declared elsewhere than node_errors.h) to node_errors.cc: - Abort() (in util.h) - Assert() (in util.h) PR-URL: https://github.com/nodejs/node/pull/24058 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-10-15async_hooks: remove promise object from resourceAndreas Madsen
While it doesn't make any difference now. In the future PromiseHooks could be refactored to provide an asyncId instead of the promise object. That would make escape analysis on promises possible. Escape analysis on promises could lead to a more efficient destroy hook, if provide by PromiseHooks as well. But at the very least would allow the destroy hook to be emitted earlier. The destroy hook not being emitted on promises frequent enough is a known and reported issue. See https://github.com/nodejs/node/issues/14446 and https://github.com/Jeff-Lewis/cls-hooked/issues/11. While all this is speculation for now, it all depends on the promise object not being a part of the PromiseWrap resource object. Ref: https://github.com/nodejs/node/issues/14446 Ref: https://github.com/nodejs/diagnostics/issues/188 PR-URL: https://github.com/nodejs/node/pull/23443 Refs: https://github.com/nodejs/node/issues/14446 Refs: https://github.com/nodejs/diagnostics/issues/188 Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: George Adams <george.adams@uk.ibm.com>
2018-10-15src: move default assignment of async_id_ in async_wrap.hDavid Corona
Moving the default assignment of async_id from the constructor in async_wrap.cc to class definition in async_wrap.h PR-URL: https://github.com/nodejs/node/pull/23495 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-10async_hooks: add missing async_hooks destroys in AsyncResetBastian Krol
This adds missing async_hooks destroy calls for sockets (in _http_agent.js) and HTTP parsers. We need to emit a destroy in AsyncWrap#AsyncReset before assigning a new async_id when the instance has already been in use and is being recycled, because in that case, we have already emitted an init for the "old" async_id. This also removes a duplicated init call for HTTP parser: Each time a new parser was created, AsyncReset was being called via the C++ Parser class constructor (super constructor AsyncWrap) and also via Parser::Reinitialize. PR-URL: https://github.com/nodejs/node/pull/23272 Fixes: https://github.com/nodejs/node/issues/19859 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-10-04src: name EmbededderGraph edges and use class names for nodesJoyee Cheung
This patch: - Refactors the `MemoryRetainer` API so that the impementer no longer calls `TrackThis()` that sets the size of node on the top of the stack, which may be hard to understand. Instead now they implements `SelfSize()` to provide their self sizes. Also documents the API in the header. - Refactors `MemoryTracker` so it calls `MemoryInfoName()` and `SelfSize()` of `MemoryRetainer` to retrieve info about them, and separate `node_names` and `edge_names` so the edges can be properly named with reference names and the nodes can be named with class names. (Previously the nodes are named with reference names while the edges are all indexed and appear as array elements). - Adds `SET_MEMORY_INFO_NAME()`, `SET_SELF_SIZE()` and `SET_NO_MEMORY_INFO()` convenience macros - Fixes a few `MemoryInfo` calls in some `MemoryRetainers` to track their references properly. - Refactors the heapdump tests to check both node names and edge names, distinguishing between wrapped JS nodes (without prefixes) and embedder wrappers (prefixed with `Node / `). PR-URL: https://github.com/nodejs/node/pull/23072 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-10-03src: use JS inheritance for `AsyncWrap`Anna Henningsen
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. PR-URL: https://github.com/nodejs/node/pull/23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-09-24src: remove calls to SetWrapperClassId()Joyee Cheung
We have migrated from the deprecated RetainedObjectInfo API to the new EmbedderGraph API, so there is no need to take care of wrapper class ids anymore since they are dedicated to the deprecated API (the new API uses a graph instead of ids to retrieve info about nodes). PR-URL: https://github.com/nodejs/node/pull/22975 Refs: https://github.com/nodejs/node/pull/21741 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-09-17src: refactor `Environment::GetCurrent()` usageAnna Henningsen
Make `Environment::GetCurrent()` return `nullptr` if the current `Context` is not a Node.js context, and for the relevant usage of this function, either: - Switch to the better `GetCurrent(args)` variant - Turn functions in to no-ops where it makes sense - Make it a `CHECK`, i.e. an API requirement, where it make sense - Leave a `TODO` comment for verifying what, if anything, is to be done PR-URL: https://github.com/nodejs/node/pull/22819 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-08-27src: move process.binding('async_wrap') internalDaniel Bevenius
This commit makes the async_wrap builtin an internal builtin, and changes usage of the builtin from using process.binding('async_wrap') to use internalBinding instead. Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/22469 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-08-10trace_events,async_hooks: use intrinsic traceJames M Snell
Switch to using the intrinsic trace event method for async_hooks. This is a breaking change because of the switch to a nested data argument for exec id and trigger id values. PR-URL: https://github.com/nodejs/node/pull/22127 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-08-07src: remove calls to deprecated v8 functions (NumberValue)Ujjwal Sharma
Remove all calls to deprecated v8 functions (here: Value::NumberValue) inside the code (src directory only). PR-URL: https://github.com/nodejs/node/pull/22094 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-08-05process: use owner_symbol for `_getActive*`Anna Henningsen
This makes it easier to provide public APIs in the return types of `process._getActiveHandles()` and `process._getActiveRequests()`. PR-URL: https://github.com/nodejs/node/pull/22002 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-08-05lib,src: standardize `owner_symbol` for handlesAnna Henningsen
Instead of somtimes using an `owner` string to link from a native handle object to the corresponding JS object, standardize on a single symbol that fulfills this role. PR-URL: https://github.com/nodejs/node/pull/22002 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-07-15src: use V8 graph heap snapshot APIAnna Henningsen
Transition to a newer, more flexible API for heap snapshot creation. This addresses a currently pending deprecation in the V8 API. PR-URL: https://github.com/nodejs/node/pull/21741 Fixes: https://github.com/nodejs/node/issues/21633 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-07-13src: enable more detailed memory trackingAnna Henningsen
This will enable more detailed heap snapshots based on a newer V8 API. This commit itself is not tied to that API and could be backported. PR-URL: https://github.com/nodejs/node/pull/21742 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-06-25src: add native debugging code to workersAnna Henningsen
Now that we have better native debugging utilities in core, let’s use them :) PR-URL: https://github.com/nodejs/node/pull/21423 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com>
2018-06-13crypto: add scrypt() and scryptSync() methodsBen Noordhuis
Scrypt is a password-based key derivation function that is designed to be expensive both computationally and memory-wise in order to make brute-force attacks unrewarding. OpenSSL has had support for the scrypt algorithm since v1.1.0. Add a Node.js API modeled after `crypto.pbkdf2()` and `crypto.pbkdf2Sync()`. Changes: * Introduce helpers for copying buffers, collecting openssl errors, etc. * Add new infrastructure for offloading crypto to a worker thread. * Add a `AsyncWrap` JS class to simplify pbkdf2(), randomBytes() and scrypt(). Fixes: https://github.com/nodejs/node/issues/8417 PR-URL: https://github.com/nodejs/node/pull/20816 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-06-05src: store pointer to Environment on DestroyParamAnatoli Papirovski
To avoid a potential segfault when inside WeakCallback, store a reference to Environment inside DestroyParam. PR-URL: https://github.com/nodejs/node/pull/21099 Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Co-authored-by: Yang Guo <yangguo@chromium.org> Co-authored-by: Michaël Zasso <targos@protonmail.com>
2018-05-31src: implement debug output utilitiesAnna Henningsen
Implement utilities for easier debugging of Node.js core code, inspired by the HTTP/2 debugging code. Debugging is, however, implemented at runtime rather than at compile time, controlled through a new `NODE_DEBUG_NATIVE=categories` environment variable. The runtime overhead in the debugging-disabled case amounts to 1 well-cachable one-byte read per debug call. PR-URL: https://github.com/nodejs/node/pull/20987 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-26src: add CHECK_NULL/CHECK_NOT_NULL macrosTobias Nießen
This change introduces CHECK_NULL and CHECK_NOT_NULL macros similar to their definition in v8 and replaces instances of CHECK/CHECK_EQ/CHECK_NE with these where it seems appropriate. PR-URL: https://github.com/nodejs/node/pull/20914 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-10src: add can_call_into_js flagAnna Henningsen
This prevents calls back into JS from the shutdown phase. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Refs: https://github.com/ayojs/ayo/pull/82 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-04src: refactor `BaseObject` internal field managementAnna Henningsen
- Instead of storing a pointer whose type refers to the specific subclass of `BaseObject`, just store a `BaseObject*` directly. This means in particular that one can cast to classes along the way of the inheritance chain without issues, and that `BaseObject*` no longer needs to be the first superclass in the case of multiple inheritance. In particular, this renders hack-y solutions to this problem (like ddc19be6de1ba263d9c175b2760696e7b9918b25) obsolete and addresses a `TODO` comment of mine. - Move wrapping/unwrapping methods to the `BaseObject` class. We use these almost exclusively for `BaseObject`s, and I hope that this gives a better idea of how (and for what) these are used in our code. - Perform initialization/deinitialization of the internal field in the `BaseObject*` constructor/destructor. This makes the code a bit more obviously correct, avoids explicit calls for this in subclass constructors, and in particular allows us to avoid crash situations when we previously called `ClearWrap()` during GC. This also means that we enforce that the object passed to the `BaseObject` constructor needs to have an internal field. This is the only reason for the test change. - Change the signature of `MakeWeak()` to not require a pointer argument. Previously, this would always have been the same as `this`, and no other value made sense. Also, the parameter was something that I personally found somewhat confusing when becoming familiar with Node’s code. - Add a `TODO` comment that motivates switching to real inheritance for the JS types we expose from the native side. This patch brings us a lot closer to being able to do that. - Some less significant drive-by cleanup. Since we *effectively* already store the `BaseObject*` pointer anyway since ddc19be6de1ba263d9c175b2760696e7b9918b25, I do not think that this is going to have any impact on diagnostic tooling. Fixes: https://github.com/nodejs/node/issues/18897 PR-URL: https://github.com/nodejs/node/pull/20455 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-04-20src: move v8::HandleScope call to EmitUjjwal Sharma
Move v8::HandleScope call to Emit removing it from previous locations where it was added to avoid crashing (constructor and destructor of AsyncWrap) for a more general and fool-proof solution. Ref: https://github.com/nodejs/node/pull/19972#issuecomment-381353894 PR-URL: https://github.com/nodejs/node/pull/20045 Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-04-12src: add node_internal.h includes for arraysizeDaniel Bevenius
This commit adds includes for node_internal.h in source files that use arraysize but don't include this header. The motivation for this is to make refactoring easier (and is the reason I noticed this). PR-URL: https://github.com/nodejs/node/pull/19916 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2018-03-30async_wrap: fix use-after-free for inspector sessionAnna Henningsen
This fixes the following condition: $ python -u tools/run-valgrind.py ./node_g test/sequential/test-inspector-async-call-stack.js [...] ==10848== Invalid read of size 4 ==10848== at 0x12F509E: node::AsyncWrap::provider_type() const (async_wrap-inl.h:34) ==10848== by 0x12E7642: node::AsyncWrap::EmitTraceEventAfter() (async_wrap.cc:208) ==10848== by 0x12F301B: node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) (async_wrap.cc:724) ==10848== by 0x14516C6: node::inspector::(anonymous namespace)::JSBindingsConnection::OnMessage(v8::Local<v8::Value>) (inspector_js_api.cc:88) ==10848== by 0x14514F1: node::inspector::(anonymous namespace)::JSBindingsConnection::JSBindingsSessionDelegate::SendMessageToFrontend(v8_inspector::StringView const&) (inspector_js_api.cc:57) ==10848== by 0x14436AD: node::inspector::(anonymous namespace)::ChannelImpl::sendMessageToFrontend(v8_inspector::StringView const&) (inspector_agent.cc:232) ==10848== by 0x1443627: node::inspector::(anonymous namespace)::ChannelImpl::sendResponse(int, std::unique_ptr<v8_inspector::StringBuffer, std::default_delete<v8_inspector::StringBuffer> >) (inspector_agent.cc:221) ==10848== by 0x15C54EA: v8_inspector::V8InspectorSessionImpl::sendProtocolResponse(int, std::unique_ptr<v8_inspector::protocol::Serializable, std::default_delete<v8_inspector::protocol::Serializable> >) (v8-inspector-session-impl.cc:165) ==10848== by 0x14C1E81: v8_inspector::protocol::DispatcherBase::sendResponse(int, v8_inspector::protocol::DispatchResponse const&, std::unique_ptr<v8_inspector::protocol::DictionaryValue, std::default_delete<v8_inspector::protocol::DictionaryValue> >) (Protocol.cpp:660) ==10848== by 0x14C1F0A: v8_inspector::protocol::DispatcherBase::sendResponse(int, v8_inspector::protocol::DispatchResponse const&) (Protocol.cpp:665) ==10848== by 0x14E68E3: v8_inspector::protocol::Debugger::DispatcherImpl::setAsyncCallStackDepth(int, std::unique_ptr<v8_inspector::protocol::DictionaryValue, std::default_delete<v8_inspector::protocol::DictionaryValue> >, v8_inspector::protocol::ErrorSupport*) (Debugger.cpp:1353) ==10848== by 0x14E2D49: v8_inspector::protocol::Debugger::DispatcherImpl::dispatch(int, v8_inspector::String16 const&, std::unique_ptr<v8_inspector::protocol::DictionaryValue, std::default_delete<v8_inspector::protocol::DictionaryValue> >) (Debugger.cpp:920) ==10848== Address 0x64e6f88 is 24 bytes inside a block of size 80 free'd ==10848== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10848== by 0x14534F8: node::inspector::(anonymous namespace)::JSBindingsConnection::~JSBindingsConnection() (inspector_js_api.cc:34) ==10848== by 0x145187E: node::inspector::(anonymous namespace)::JSBindingsConnection::Disconnect() (inspector_js_api.cc:111) ==10848== by 0x14518C9: node::inspector::(anonymous namespace)::JSBindingsConnection::Disconnect(v8::FunctionCallbackInfo<v8::Value> const&) (inspector_js_api.cc:117) ==10848== by 0x166FF87: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) (api-arguments.cc:26) ==10848== by 0x172F829: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (builtins-api.cc:112) ==10848== by 0x172D85C: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) (builtins-api.cc:142) ==10848== by 0x172D5F6: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) (builtins-api.cc:130) ==10848== by 0x7895E1842C3: ??? ==10848== by 0x7895E19B737: ??? ==10848== by 0x7895E19B737: ??? ==10848== by 0x7895E18F9C2: ??? ==10848== Block was alloc'd at ==10848== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10848== by 0x14517E8: node::inspector::(anonymous namespace)::JSBindingsConnection::New(v8::FunctionCallbackInfo<v8::Value> const&) (inspector_js_api.cc:103) ==10848== by 0x166FF87: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) (api-arguments.cc:26) ==10848== by 0x172F113: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (builtins-api.cc:112) ==10848== by 0x172D748: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) (builtins-api.cc:138) ==10848== by 0x172D5F6: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) (builtins-api.cc:130) ==10848== by 0x7895E1842C3: ??? ==10848== by 0x7895E1930DC: ??? ==10848== by 0x7895E293EAA: ??? ==10848== by 0x7895E19B737: ??? ==10848== by 0x7895E19B737: ??? ==10848== by 0x7895E19B737: ??? [...] PR-URL: https://github.com/nodejs/node/pull/19381 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-03-18src: make AsyncWrap constructors delegateDaniel Bevenius
Currently, there is an AsyncWrap constructor that is only used by PromiseWrap. This constructor has a body which is very similar to the other AsyncWrap constructor. This commit suggests updating the private constructor that is used by PromiseWrap and also have the second constructor delegate to this one to avoid the code duplication. PR-URL: https://github.com/nodejs/node/pull/19366 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-16src: remove unused uv.h include from async_wrap.ccDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/19342 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Khaidi Chu <i@2333.moe>
2018-03-16src: fix indenting of wrap->EmitTraceEventBeforeDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/19340 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-16src: add extractPromiseWrap functionDaniel Bevenius
Currently PromiseHook extracts the PromiseWrap from a Local<Promise> in two places. This commit extracts that code into a function instead. PR-URL: https://github.com/nodejs/node/pull/19340 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-14src: refactor emit before/after/promiseResolveDaniel Bevenius
Currently EmitBefore, EmitAfter, EmitPromiseResolve are very similar. This commit suggests extracting the code they have in common to a new function to reduce code duplication. PR-URL: https://github.com/nodejs/node/pull/19295 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-11src: add convenience ctor for async trigger id scopeAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/19204 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-03-09src: add tracing category macrosJames M Snell
Adds `TRACING_CATEGORY_NODE`, `TRACING_CATEGORY_NODE1` and `TRACING_CATEGORY_NODE2` helper macros for consistently building trace event category strings. For instance, `TRACING_CATEGORY_NODE2(foo, bar)` would generate the category string `node,node.foo,node.foo.bar`, such that... ``` TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( TRACING_CATEGORY_NODE2(foo, bar), "baz", 1); ``` Would emit if trace events are enabled for categories: `node`, `node.foo`, or `node.foo.bar`. This allows a natural scoping down of what trace events a user may want to receive. Enabling the `node` category would receive everything Node.js produces. PR-URL: https://github.com/nodejs/node/pull/19155 Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2018-03-08src: use smart pointer in AsyncWrap::WeakCallbackDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/19168 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-02-22src: fix abort when taking a heap snapshotBen Noordhuis
Remove an erroneous CHECK that asserted the persistent object's internal field pointer still pointed to a valid object. If ClearWrap() has been called, the field pointer equals nullptr and that is expected behavior. PR-URL: https://github.com/nodejs/node/pull/18898 Fixes: https://github.com/nodejs/node/issues/18256 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <matheus@sthima.com>
2018-02-22src: remove unused using declarations async_wrapDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/18893 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2018-02-21src: remove unnecessary Reset() callsBen Noordhuis
The previous commit made persistent handles auto-reset on destruction. This commit removes the Reset() calls that are now no longer necessary. PR-URL: https://github.com/nodejs/node/pull/18656 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-02-21src: prevent persistent handle resource leaksBen Noordhuis
Replace v8::Persistent with node::Persistent, a specialization that resets the persistent handle on destruction. Prevents accidental resource leaks when forgetting to call .Reset() manually. I'm fairly confident this commit fixes a number of resource leaks that have gone undiagnosed so far. PR-URL: https://github.com/nodejs/node/pull/18656 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-02-16async_hooks: clean up usage in internal codeAnatoli Papirovski
Instead of exposing internals of async_hooks & async_wrap throughout the code base, create necessary helper methods within the internal async_hooks that allows easy usage by Node.js internals. This stops every single internal user of async_hooks from importing a ton of functions, constants and internal Aliased Buffers from C++ async_wrap. Adds functions initHooksExist, afterHooksExist, and destroyHooksExist to determine whether the related emit methods need to be triggered. Adds clearDefaultTriggerAsyncId and clearAsyncIdStack on the JS side as an alternative to always calling C++. Moves async_id_symbol and trigger_async_id_symbol to internal async_hooks as they are never used in C++. Renames newUid to newAsyncId for added clarity of its purpose. Adjusts usage throughout the codebase, as well as in a couple of tests. PR-URL: https://github.com/nodejs/node/pull/18720 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-02-12async_hooks: rename PromiseWrap.parentIdAli Ijaz Sheikh
Rename the `parentId` property on the PromiseWrap object to a `isChainedPromise` property. The former wasn't quite useful as it was always defined to be the same value as the trigger id available in the init hook. Instead rename the property to be closer to the information it communicates: whether the promise is a chained promise or not. PR-URL: https://github.com/nodejs/node/pull/18633 Fixes: https://github.com/nodejs/node/issues/18470 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-02-01async_hooks: clean up commentsAli Ijaz Sheikh
With some of the recent work, some of the comments were no longer representative of the code, or were otherwise unclear. This commit fixes some obvious issues I found. Ref: https://github.com/nodejs/node/commit/83e5215a4e8438a43b9f0002b7a43e2fd2dd37a4 Ref: https://github.com/nodejs/node/commit/0784b0440c05464f79b857f7d8698fcc953d3fb3 PR-URL: https://github.com/nodejs/node/pull/18467 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-01-21async_wrap: schedule destroy hook as unrefAnatoli Papirovski
Since the `DestroyAsyncIdsCallback` in Node.js can be scheduled as a result of GC, that means that it can accidentally keep the event loop open when it shouldn't. Replace `SetImmediate` with the newly introduced `SetUnrefImmediate` and in addition introduce RunBeforeExit callbacks, of which `DestroyAsyncIdsCallback` is now the first. These callbacks will run before the `beforeExit` event is emitted (which will now only be emitted if the event loop is still not active). PR-URL: https://github.com/nodejs/node/pull/18241 Fixes: https://github.com/nodejs/node/issues/18190 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2018-01-02src: remove duplicate words in commentsTobias Nießen
PR-URL: https://github.com/nodejs/node/pull/17939 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com>