profile
viewpoint
Ben Noordhuis bnoordhuis IBM The Netherlands

bnoordhuis/bspc 20

Quake 3 BSP-to-AAS compiler

bnoordhuis/amazing-graceful-fs 4

Like graceful-fs, but without eval() hacks and polyfills.

bnoordhuis/chicken-core 4

http://call-cc.org/

bnoordhuis/axis2-c 3

Apache Axis2/C is a Web services engine implemented in the C programming language.

bnoordhuis/chamfilter 3

block China and other South Asian countries at the firewall level

bnoordhuis/entityplus 3

just another quake 3 mod

bnoordhuis/c-ares 2

c-ares is a C library that performs DNS requests and name resolves asynchronously.

Pull request review commentnodejs/node

src: revamp internal field count tracking

 void LibuvStreamWrap::Initialize(Local<Object> target,   Local<FunctionTemplate> sw =       FunctionTemplate::New(env->isolate(), is_construct_call_callback);   sw->InstanceTemplate()->SetInternalFieldCount(-      StreamReq::kStreamReqField + 1 + 3);+      StreamReq::kInternalFieldCount + 3);

As mentioned above, this looks highly dubious. :-)

jasnell

comment created time in an hour

Pull request review commentnodejs/node

src: revamp internal field count tracking

 PromiseWrap* PromiseWrap::New(Environment* env,   obj->SetInternalField(PromiseWrap::kIsChainedPromiseField,                         parent_wrap != nullptr ? v8::True(env->isolate())                                                : v8::False(env->isolate()));-  CHECK_NULL(promise->GetAlignedPointerFromInternalField(0));-  promise->SetInternalField(0, obj);+  CHECK_NULL(promise->GetAlignedPointerFromInternalField(BaseObject::kSlot));+  promise->SetInternalField(BaseObject::kSlot, obj);   return new PromiseWrap(env, obj, silent); }  void PromiseWrap::getIsChainedPromise(Local<String> property,                                       const PropertyCallbackInfo<Value>& info) {   info.GetReturnValue().Set(-    info.Holder()->GetInternalField(kIsChainedPromiseField));+      info.Holder()->GetInternalField(PromiseWrap::kIsChainedPromiseField)); }  static PromiseWrap* extractPromiseWrap(Local<Promise> promise) {-  Local<Value> resource_object_value = promise->GetInternalField(0);-  if (resource_object_value->IsObject()) {+  Local<Value> resource_object_value =+      promise->GetInternalField(BaseObject::kSlot);+  if (resource_object_value->IsObject())

I know it's existing logic but if IsObject() == false, then what's resource_object_value instead?

From quick grepping I infer base_object-inl.h sets it to this? It's not safe to call SetAlignedPointerInInternalField(), then read it back as a Local<Value>.

jasnell

comment created time in an hour

Pull request review commentnodejs/node

src: revamp internal field count tracking

 class BaseObjectPtrImpl;  class BaseObject : public MemoryRetainer {  public:+  enum InternalFields : int { kSlot, kInternalFieldCount };
  enum InternalFields { kSlot, kInternalFieldCount };

Or declare them int everywhere, either is fine as long as it's consistent.

jasnell

comment created time in an hour

Pull request review commentnodejs/node

src: revamp internal field count tracking

 using JSMethodFunction = void(const v8::FunctionCallbackInfo<v8::Value>& args);  class StreamReq {  public:-  static constexpr int kStreamReqField = 1;+  enum InternalFields {+    kStreamReqField = BaseObject::kInternalFieldCount,

This doesn't look right. StreamReq doesn't derive from BaseObject.

The way StreamReq::kStreamReqField is currently used (not in this PR) looks very dubious to me:

sw->InstanceTemplate()->SetInternalFieldCount(StreamReq::kStreamReqField + 1 + 3);

I mean, what?

jasnell

comment created time in an hour

Pull request review commentnodejs/node

src: revamp internal field count tracking

 class StreamResource {  class StreamBase : public StreamResource {  public:-  // 0 is reserved for the BaseObject pointer.-  static constexpr int kStreamBaseField = 1;-  static constexpr int kOnReadFunctionField = 2;-  static constexpr int kStreamBaseFieldCount = 3;+  enum InternalFields {+    kStreamBaseField = BaseObject::kInternalFieldCount,

This doesn't look right either for much the same reason, but also because it requires you to check that StreamResource isn't a BaseObject or uses fields itself.

Aside: I don't really understand why StreamResource is a separate class. It looks like it can be merged into StreamBase.

jasnell

comment created time in an hour

Pull request review commentnodejs/node

src: revamp internal field count tracking

 namespace node {  class ObjectWrap {  public:+  enum InternalFields { kSlot, kInternalFieldCount };
  enum InternalFields { kSlot, kInternalFieldCount };
  

But I'd probably skip the enumification treatment for this file. Node.js itself doesn't use it and, since ObjectWrap is a public API, the enum shows up in classes that inherit from it.

jasnell

comment created time in an hour

issue commentnodejs/node

crash on mipsel64 from v12.x

https://github.com/nodejs/node/issues/31118#issuecomment-591221731 looks like a C++ -> JS function call gone wrong but I can't really tell more from the backtrace.

It looks like this function call:

https://github.com/nodejs/node/blob/db125c561880d8b2b272fb85c7a3baa91fcec31a/src/api/environment.cc#L462-L471

cc @joyeecheung - that code seems to have undergone quite some changes recently so perhaps this is a known and already fixed issue?

@FlyGoat You might want to try out the HEAD of the v12.x-staging branch, see if that works better.

whhif

comment created time in 2 hours

issue commentnodejs/node

Repeated socket data events can block timers, etc

Why 32 events?

It's really just a circuit breaker. See libuv/libuv@738b31eb3aff440ae75ff9f32ba61086a948c3f4 for rationale.

From the linked issue I infer that mysqljs consumes data in "fire hose" mode and doesn't apply back-pressure.

One solution is to record timestamps when data comes in and pause the socket when the amount of data within a time window exceeds a threshold.

logidelic

comment created time in 2 hours

issue commentnodejs/node

Initialization code for native node module not called on windows, ie. DLL init missing

More recent node-gyp versions support python 3.

Superlokkus

comment created time in 2 hours

Pull request review commentnodejs/node

dgram: make UDPWrap more reusable

 void UDPWrap::Initialize(Local<Object> target,   Environment* env = Environment::GetCurrent(context);    Local<FunctionTemplate> t = env->NewFunctionTemplate(New);-  t->InstanceTemplate()->SetInternalFieldCount(1);+  t->InstanceTemplate()->SetInternalFieldCount(kUDPWrapBaseField + 1);

That's not good enough. If for whatever reason BaseObject needs to use two slots instead of one, the code here will break in unexpected and probably interesting ways. There's no reason not to get this right from the start.

jasnell

comment created time in 15 hours

issue commentnodejs/node

"heap out of memory" because strings are kept in memory when 13 chars substrings are referenced

--nostring_slices disables them but caveat emptor, you probably need to build node from source with ./configure --v8-options=--nostring_slices for it to be fully effective, otherwise the snapshot won't honor it. You could submit a fix for that to V8.

andiby

comment created time in 15 hours

issue commentnodejs/node

Repeated socket data events can block timers, etc

There's a threshold (node/libuv moves on after 32 consecutive packets from the same socket) but the One Rule of event-driven programming is simply this: don't block.

If you have some kind of long-running computation, move it to a worker or a child process.

logidelic

comment created time in 15 hours

issue commentnodejs/node

Australia timezone issues

Closing. Please fill out the issue template next time.

praveenpinto

comment created time in 15 hours

issue closednodejs/node

Australia timezone issues

<!-- Thank you for reporting an issue.

This issue tracker is for bugs and issues found within Node.js core. If you require more general support please file an issue on our help repo. https://github.com/nodejs/help

Please fill in as much of the template below as you're able.

Platform: output of uname -a (UNIX), or version and 32 or 64-bit (Windows) Subsystem: if known, please specify affected core module name -->

  • Version:
  • Platform:
  • Subsystem:

What steps will reproduce the bug?

<!-- Linux CentOS Linux release 7.6.1810 Docker 17.06-2 Node 12.14.1 running following command in docker container where the timezone of server is Australia/Sydney gives undefined.

Intl.DateTimeFormat().resolvedOptions().timeZone gives undefined, instead of the actual time for Australia/Sydney -->

How often does it reproduce? Is there a required condition?

What is the expected behavior?

<!-- Time for Australia/Sydney should be given -->

What do you see instead?

<!-- /app # node Welcome to Node.js v12.14.1. Type ".help" for more information.

Intl.DateTimeFormat().resolvedOptions().timeZone undefined -->

Additional information

<!-- Tell us anything else you think we should know. -->

closed time in 15 hours

praveenpinto

issue closednodejs/node

Using node --flag, check if loaded dependencies versions match expected versions

Of course, NPM + package.json are not Node.js perse - so this feature would have to work independently of a package manager.

I put the question on SO: https://stackoverflow.com/questions/60367401/throw-error-if-loaded-package-version-does-not-match-package-version-in-package

Perhaps there could be some declarative file like package.json that told Node.js what version of a package should be loaded at runtime. The main motivation is to prevent accidentally using the wrong version of a library when running code - this happens often because node_modules is not in version control for most users.

For a language that's not compiled, this would help I think. The most common use case is doing:

git pull
node .

instead of doing

git pull
npm i
node .

there might be other solutions to this problem and I am interesting in discussing alternatives I guess.

closed time in 15 hours

ORESoftware

issue commentnodejs/node

Using node --flag, check if loaded dependencies versions match expected versions

I'm with @tniessen that I don't think a flag is an improvement over the status quo. Use a Makefile if you want to ensure npm install always runs when package.json is touched.

ORESoftware

comment created time in 15 hours

issue commentnodejs/node

Repeated socket data events can block timers, etc

JS is not reentrant. If a function busy-loops, it busy-loops. Therefore, this...

Presumably, timer callbacks should be scheduled fairly vs socket data events...

...is not a reasonable expectation. If you have concrete suggestions for improvement, please let me know, but otherwise there isn't anything actionable here.

logidelic

comment created time in 15 hours

pull request commentnodejs/node

[v10.x] tls: expose keylog event on TLSSocket

It's okay to disable the functionality with #if OPENSSL_VERSION_NUMBER < 0x1010100fL. That buildbot is so we know when a change breaks distro builds.

mildsunrise

comment created time in 15 hours

pull request commentnodejs/node

src: use _init as the start of large pages

Could you remind me why we are not using the linker script?

They're hard to keep portable across ld.bfd, ld.gold and ld.ldd.

We want to relocate as much of the .text segment so finding a symbol that is at the very beginning is what we need.

We scan /proc/self/maps for a mapping that contains a symbol. I don't see why it matters if that symbol is at the start, the end or somewhere in the middle of that segment; it's copied whole.

gabrielschulhof

comment created time in 17 hours

issue commentlibuv/libuv

unix,fs: returning error on partial writes

I'm not sure what extra write() you mean. We don't know a partial write is going to be followed by ENOSPC until we try to write again.

santigimeno

comment created time in 18 hours

pull request commentnodejs/node

src: use _init as the start of large pages

I'm testing with clang 9 but even after grepping through the llvm+clang+lld source tree I haven't really narrowed down what causes clang to emit them or not. 🤷‍♂

At any rate, does it matter where main is located? As long as it's somewhere in the text segment that you want to relocate, right?

gabrielschulhof

comment created time in 18 hours

issue commentnodejs/help

UDP Dgram ERR_SOCKET_CANNOT_SEND

You're trying to send data before the socket has been bound. Node tries to do that implicitly for you but the operation fails, presumably because either the address is already in use or because the bind address is wrong.

Either way, you should get a more legible error when you move the server.send(...) call inside your server.on("listening", ...) event listener. Right now, that ERR_SOCKET_CANNOT_SEND is masquerading the real error.

cc @cjihrig I see you added that in nodejs/node@5587ff1ccd9. It might be better to forward the original listen error?

Luuccc

comment created time in 20 hours

issue commentnodejs/help

Behavior of Promise.all with Promises that resolve a Stream

You have to clean up manually, if I understand your question correctly. There's no way for node to know the stream isn't going to be used. Promise.p.finally might come in handy.

nanokina

comment created time in 21 hours

pull request commentnodejs/node

crypto: optimize sign.update() and verify.update()

@tniessen I'm afraid I'm not following. If you want to open an alternate PR, I'll be happy to review it and abandon this one.

bnoordhuis

comment created time in 21 hours

pull request commentnodejs/node

src: use _init as the start of large pages

clang++ seems pretty averse to emitting _init and _fini symbols, probably because they've been deprecated for I don't know how long. Perhaps you can use main instead?

on Skylake CPUs where the whole code resides in one mapping

That's interesting, do you know why that is? The current parser can probably be made to accommodate that without switching to a different symbol.

gabrielschulhof

comment created time in 21 hours

created tagbnoordhuis/v8-cmake

tag8.1.307.13

The V8 JavaScript engine, but built with CMake instead of GN - WIP

created time in 4 days

create barnchbnoordhuis/v8-cmake

branch : 8.1

created branch time in 4 days

push eventbnoordhuis/v8-cmake

Ben Noordhuis

commit sha 81322c03f6104b3bedb5fe9de06224802ba155f8

8.1.307.13

view details

push time in 4 days

Pull request review commentdenoland/deno

feat(std/node): add os Symbol.toPrimitive methods

 interface UserInfo {   homedir: string; } +arch[Symbol.toPrimitive] = (): string => arch();

I know the answer but it's the wrong question to ask, IMO. Node is so widely used that chances are > 50% that there's some code somewhere depends on this particular quirk. Even if Node's test suite didn't test for it, that doesn't mean we can just deviate.

Random example: people complained their code broke when the util.inspect() representation of streams changed in a really minor way. When the user base is big enough, any change is going to get noticed by someone.

bnoordhuis

comment created time in 4 days

create barnchbnoordhuis/v8-cmake

branch : 8.0

created branch time in 4 days

created tagbnoordhuis/v8-cmake

tag8.0.426.25

The V8 JavaScript engine, but built with CMake instead of GN - WIP

created time in 4 days

push eventbnoordhuis/v8-cmake

Ben Noordhuis

commit sha 866665878375728688c6f3560051a86527fe9437

8.0.426.25

view details

push time in 4 days

Pull request review commentdenoland/deno

feat(std/node): add os Symbol.toPrimitive methods

 interface UserInfo {   homedir: string; } +arch[Symbol.toPrimitive] = (): string => arch();

Because that's how Node.js does it. I figured that if we're adding a compatibility shim, we might as well aim for 100% fidelity. :-)

There's an observable difference in that os.arch[Symbol.toPrimitive].name is the empty string in Node.js but it would be 'arch' with your suggestion, i.e., it'd print differently.

bnoordhuis

comment created time in 4 days

Pull request review commentlibuv/libuv

zos: return on realloc failure in scandir()

 int scandir(const char* maindir, struct dirent*** namelist,       struct dirent* copy;       copy = uv__malloc(sizeof(*copy));       if (!copy) {-        while (count) {-          dirent = nl[--count];-          uv__free(dirent);-        }-        uv__free(nl);-        closedir(mdir);-        errno = ENOMEM;-        return -1;+        goto error;       }       memcpy(copy, dirent, sizeof(*copy));        nl = uv__realloc(nl, sizeof(*copy) * (count + 1));+      if (nl == NULL) {+        uv__free(copy);

This is just me thinking aloud but it might be good to introduce uv__reallocf() (inspired by freebsd's reallocf(3)) that frees the memory on realloc failure.

miladfarca

comment created time in 5 days

Pull request review commentlibuv/libuv

zos: return on realloc failure in scandir()

 int scandir(const char* maindir, struct dirent*** namelist,    *namelist = nl;   return count;++error:+  while (count) {
  while (count > 0) {
miladfarca

comment created time in 5 days

Pull request review commentlibuv/libuv

zos: return on realloc failure in scandir()

 int scandir(const char* maindir, struct dirent*** namelist,       struct dirent* copy;       copy = uv__malloc(sizeof(*copy));       if (!copy) {-        while (count) {-          dirent = nl[--count];-          uv__free(dirent);-        }-        uv__free(nl);-        closedir(mdir);-        errno = ENOMEM;-        return -1;+        goto error;

Can you drop the braces? Thanks.

miladfarca

comment created time in 5 days

issue commentnodejs/node

Error reporting being sent to stdout rather than stderr

That's not under node's control, those messages are printed by the V8 engine.

CalebCarroll

comment created time in 5 days

PR opened FillZpp/sys-info-rs

include build number in os_release() on Windows

For compatibility with libuv's uv_os_uname() function.

+2 -2

0 comment

1 changed file

pr created time in 5 days

create barnchbnoordhuis/sys-info-rs

branch : windows-os_release-build-number

created branch time in 5 days

fork bnoordhuis/sys-info-rs

Get system information in Rust.

fork in 5 days

Pull request review commentdenoland/deno

Add missing node os.release() implementation

 fn op_hostname(   let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_owned());   Ok(JsonOp::Sync(json!(hostname))) }++fn op_os_release(+  state: &State,+  _args: Value,+  _zero_copy: Option<ZeroCopyBuf>,+) -> Result<JsonOp, ErrBox> {+  state.check_env()?;+  let release = sys_info::os_release().unwrap_or_else(|_| "".to_owned());

With Node.js, os.release() on Windows returns "<major>.<minor>.<build>" whereas sys_info::os_release() returns just "<major>.<minor>".

I could PR a change to sys_info adding the build number but we seem to have pinned it to an older version because of Windows breakage in the latest version...

ecyrbe

comment created time in 5 days

issue commentdenoland/deno

Add Node.js native module polyfills to std/node

Is there consensus on if or how much of node's crypto module to reimplement?

It's got a pretty big API surface and openssl-isms leak through in many places but it should be possible to make basic functionality (cipher/decipher/hash/hmac/sign/verify) work for the most common ciphers and hashes using RustCrypto.

kevinkassimo

comment created time in 5 days

PR opened denoland/deno

feat(std/node): add os Symbol.toPrimitive methods

Node's os module exports a number of methods that evaluate to themselves when coerced to a primitive.

I.e., "" + os.arch and os.arch() evaluate to the same string, and now Deno's shims do too.

+22 -0

0 comment

2 changed files

pr created time in 5 days

create barnchbnoordhuis/deno

branch : node-os-toprimitive-coercion

created branch time in 5 days

push eventbnoordhuis/libuv

erw7

commit sha 18ff13c71e5e68066729bc90664f9550bfe5ead4

doc: add erw7 to maintainers PR-URL: https://github.com/libuv/libuv/pull/2662 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Jameson Nash <vtjnash@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>

view details

Marek Vavrusa

commit sha 618533b7e3ba4b9e86d870a4ab59f147fa20566b

test: fixed udp4_echo_server implementation It was missing socket binding and the on_recv() callback was wrong. PR-URL: https://github.com/libuv/libuv/pull/2532 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

view details

Marek Vavrusa

commit sha 56598f3d10fbb48705bba3149c995092d832bb62

test: added udp ping benchmark (1,10,100 pingers) The UDP pummel benchmark does not model usual UDP servers well, in UDP services like DNS, DHCP or NTP, there is usually just one socket bound to the registered port and a large number of requestors asking queries, this benchmark is simple 1 sender : 1 receiver thread benchmark with multiple senders multiplexing on the event loop. The test reports number of senders and attained rate of requests, and is based on TCP benchmark-ping-pong.c. PR-URL: https://github.com/libuv/libuv/pull/2532 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

view details

Marek Vavrusa

commit sha 3d7136639a39db46bc4a9074922559a564e49514

freebsd,linux: add recvmmsg() + sendmmsg() udp implementation This commits adds support for recvmmsg() and sendmmsg() extensions to recvmsg() and sendmsg() that allows the caller to receive and send multiple message from a socket using a single system call. This has performance benefits for some applications. Co-authored-by: Ondřej Surý <ondrej@sury.org> Co-authored-by: Witold Kręcicki <wpk@culm.net> PR-URL: https://github.com/libuv/libuv/pull/2532 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

view details

Ben Noordhuis

commit sha 2884360ae71f2fe19c8d8e496ac056855c5e7125

build: remove support for gyp Upstream GYP has been unmaintained for some time now. The only big downstream user is Node.js and they already maintain GYP build files for their other dependencies. This commit removes vcbuild.bat because: 1. it's entirely built around GYP, and 2. duplicates a lot of functionality that cmake provides out of the box This commit also removes appveyor.yml. It hasn't been used after we stopped providing prebuilt binaries for Windows about two years ago. As if that isn't enough, this commit also removes the Android build scripts. They were wrappers around GYP. Use CMake. Refs: https://github.com/libuv/libuv/pull/2681

view details

push time in 5 days

pull request commentlibuv/libuv

build: remove support for gyp

And @piscisaureus too!

bnoordhuis

comment created time in 5 days

pull request commentlibuv/libuv

build: remove support for gyp

@jBarz @imran-iq @indutny @refack That's your call. :-)

bnoordhuis

comment created time in 5 days

pull request commentlibuv/libuv

build: remove support for gyp

ideally a GitHub group

@libuv/collaborators? I'm considering removing people that haven't been active in the last year, that cuts it down to about 10 people.

bnoordhuis

comment created time in 5 days

pull request commentnodejs/node

build: add asan check in Github action

Seems like a good idea but how long does make test take for an asan+debug build?

gengjiawen

comment created time in 5 days

Pull request review commentnodejs/node

src: include large pages source unconditionally

 static bool IsSuperPagesEnabled() { } #endif +int IsLargePagesEnabled() {

Can you name this e.g. GetLargePagesSupport()? IsLargePagesEnabled() suggests it returns a boolean when it doesn't.

Alternatively, you could just inline it at the call site; there's only one caller.

gabrielschulhof

comment created time in 5 days

Pull request review commentnodejs/node

src: include large pages source unconditionally

 MoveTextRegionToLargePages(const text_region& r) {  // This is the primary API called from main. int MapStaticCodeToLargePages() {+  int is_enabled = IsLargePagesEnabled();+  if (is_enabled != 0) {+    return is_enabled;+  }   struct text_region r = FindNodeTextRegion();   if (r.found_text_region == false) {-    PrintWarning("failed to find text region");-    return -1;+    return ENOENT;   }

Can you drop the braces?

gabrielschulhof

comment created time in 5 days

push eventbnoordhuis/fth

Ben Noordhuis

commit sha ea7cd9509e4dddf694e11c29759d46802d7b6f87

implement binops in terms of 0= primitive Before this commit they were implemented in terms of the < primitive but that requires awkward stack juggling to implement <>. Using 0= is both more elegant and produces better code.

view details

push time in 5 days

create barnchbnoordhuis/fth

branch : master

created branch time in 5 days

created repositorybnoordhuis/fth

a not-quite-Forth-to-LLVM-bitcode compiler

created time in 5 days

issue commentnodejs/help

Small changes on objects doesn't fire the proxy...

Moving to nodejs/help because this is working as per spec. I recommend you consult MDN or the ECMA spec on how proxies work.

mnini

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))+          && pathw[1] == L':' && (pathw[2] == L'\\' || pathw[2] == L'/')) {+        /* Start with <dirve>:[\/]. Absolute paths. */+        pathw[3] = L'\0';+      } else if ((pathw[0] == L'\\' || pathw[0] == L'/')+                  && (pathw[0] == L'\\' || pathw[1] == L'/')) {+        /* Start with [\/][\/]. The path is either a UNC path(\\server\share\)+         * or a DOS device path(\\.\C:\Windows, \\?\C:\Windows,+         * \\?\Volume{...}\Test), so the second path separator is end of the+         * root directory. */+        WCHAR* ptr;+        int count;++        count = 0;+        ptr = pathw + 3;+        while (*ptr) {+          if (*ptr == L'\\' || *ptr == L'/')+            count++;+          if (count == 2) {

This doesn't handle enough cases, it looks like. It'll match foo/bar/baz but also e.g. foo/bar/ or foo//bar. Those are all legal paths.

erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))+          && pathw[1] == L':' && (pathw[2] == L'\\' || pathw[2] == L'/')) {+        /* Start with <dirve>:[\/]. Absolute paths. */+        pathw[3] = L'\0';+      } else if ((pathw[0] == L'\\' || pathw[0] == L'/')+                  && (pathw[0] == L'\\' || pathw[1] == L'/')) {+        /* Start with [\/][\/]. The path is either a UNC path(\\server\share\)+         * or a DOS device path(\\.\C:\Windows, \\?\C:\Windows,+         * \\?\Volume{...}\Test), so the second path separator is end of the+         * root directory. */+        WCHAR* ptr;+        int count;++        count = 0;+        ptr = pathw + 3;

Out of bounds when pathw = L"//\0".

erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))+          && pathw[1] == L':' && (pathw[2] == L'\\' || pathw[2] == L'/')) {+        /* Start with <dirve>:[\/]. Absolute paths. */+        pathw[3] = L'\0';+      } else if ((pathw[0] == L'\\' || pathw[0] == L'/')+                  && (pathw[0] == L'\\' || pathw[1] == L'/')) {+        /* Start with [\/][\/]. The path is either a UNC path(\\server\share\)+         * or a DOS device path(\\.\C:\Windows, \\?\C:\Windows,+         * \\?\Volume{...}\Test), so the second path separator is end of the+         * root directory. */+        WCHAR* ptr;+        int count;++        count = 0;+        ptr = pathw + 3;+        while (*ptr) {
        while (*ptr != L'\0') {
erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))+          && pathw[1] == L':' && (pathw[2] == L'\\' || pathw[2] == L'/')) {+        /* Start with <dirve>:[\/]. Absolute paths. */
        /* Start with <drive>:[\/]. Absolute paths. */
erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))

Stylistic nit: || goes on the previous line. Ditto for the && on line 2669.

erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {

Can this actually happen? len starts out as MAX_PATH + 1, right?

erw7

comment created time in 5 days

Pull request review commentlibuv/libuv

win,fs: fix problems with passing file names to uv_fs_statfs

 static void fs__statfs(uv_fs_t* req) {                              &bytes_per_sector,                              &free_clusters,                              &total_clusters)) {-    SET_REQ_WIN32_ERROR(req, GetLastError());-    return;+    DWORD err;++    err = GetLastError();+    if (err == ERROR_DIRECTORY) {+      WCHAR* pathw;+      size_t len;+      DWORD ret;++      len = MAX_PATH + 1;+      pathw = uv__malloc(len * sizeof(*pathw));+retry:+      ret = GetFullPathNameW(req->file.pathw,+                             len,+                             pathw,+                             NULL);+      if (ret == 0) {+        uv__free(pathw);+        SET_REQ_WIN32_ERROR(req, err);+        return;+      } else if (ret > len) {+        WCHAR* saved_pathw;++        len = ret;+        saved_pathw = pathw;+        pathw = uv__realloc(pathw, len * sizeof(*pathw));+        if (pathw == NULL) {+          uv__free(saved_pathw);+          SET_REQ_WIN32_ERROR(req, err);+          return;+        }+        goto retry;+      }++      if (((pathw[0] >= L'A' && pathw[0] <= L'Z')+            || (pathw[0] >= L'a' && pathw[0] <= L'z'))+          && pathw[1] == L':' && (pathw[2] == L'\\' || pathw[2] == L'/')) {+        /* Start with <dirve>:[\/]. Absolute paths. */+        pathw[3] = L'\0';+      } else if ((pathw[0] == L'\\' || pathw[0] == L'/')+                  && (pathw[0] == L'\\' || pathw[1] == L'/')) {
                  && (pathw[1] == L'\\' || pathw[1] == L'/')) {

I think?

erw7

comment created time in 5 days

issue openedlibuv/libuv

os390: OOB write on realloc failure in scandir()

https://github.com/libuv/libuv/blob/3d7136639a39db46bc4a9074922559a564e49514/src/unix/os390-syscalls.c#L77-L78

created time in 5 days

issue closednodejs/node

Proxy's setter doesn't return on assign.

var variable = {
        thisIsObject: true;
}
var prox = new Proxy(variable, {
        get: function(obj, prop) {
            return obj[prop]
        },
        set: function(obj, prop, newval) {
            obj[prop] = newval
            return 'this.should.be.visible'
        }
    })
console.log( prox.var= 'new variable' )

I just thing, that this is where assign should work like this. Now it just returns value of being set, but if I would like to overwrite that ever, I would do it like this.

I don't think it's standard javascript feature, but it's bug that it's not happening.

If you fix it first, I think another .js implementations will catch.

I think it's bug, when return doesn't returns return.

closed time in 5 days

mnini

issue commentnodejs/node

Proxy's setter doesn't return on assign.

That's the behavior mandated by the spec. Note that it's also how setters works - their return value is ignored.

Closing, not a bug.

mnini

comment created time in 5 days

issue commentnodejs/help

Syslog without external modules?

No, because there's no way to open /dev/log in AF_UNIX+SOCK_DGRAM mode.

Really old versions of node supported that as dgram.createSocket('unix_dgram') but that was removed when node was ported to Windows (and hence why I wrote node-unix-dgram.)

You can use socat(1) to create the socket, then pass the file descriptor to Node.js and use it with dgram.createSocket('udp4').bind({ fd: 3 }).

Andreyooo

comment created time in 5 days

issue commentnodejs/help

Request with cert and key fails with 'certificate has expired' but same works with CURL

I'm moving this to nodejs/help. If you can post steps to reproduce and it turns out it's an issue with Node.js itself, I'll move it back.

pnsvinodkumar

comment created time in 5 days

issue closednodejs/node

< /usr/bin/node: bad option: --inspect-brk=9229

  • v12.14.0
  • ARM

What steps will reproduce the bug?

Trying to run a Node app with the inspect flag node inspect server.js

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Debugger should work

What do you see instead?

< /usr/bin/node: bad option: --inspect-brk=9229

Additional information

I'm building Node with Buildroot

closed time in 5 days

kdubious

issue commentnodejs/node

< /usr/bin/node: bad option: --inspect-brk=9229

You should report this to whoever maintains the buildroot package. My guess is node is configured with ./configure --without-inspector.

kdubious

comment created time in 5 days

issue closednodejs/node

Initialization code for native node module not called on windows, ie. DLL init missing

<!-- Thank you for reporting an issue.

This issue tracker is for bugs and issues found within Node.js core. If you require more general support please file an issue on our help repo. https://github.com/nodejs/help

Please fill in as much of the template below as you're able.

Version: output of node -v Platform: output of uname -a (UNIX), or version and 32 or 64-bit (Windows) Subsystem: if known, please specify affected core module name -->

  • Version: v10.16.3
  • Platform: Windows 10 1909
  • Subsystem: MSVC 14.24.2831

What steps will reproduce the bug?

git clone git@github.com:Superlokkus/spielwiese.git
git checkout napi_linking_problems_statics 
yarn install
yarn test

How often does it reproduce? Is there a required condition?

On windows, using MSVC for build

What is the expected behavior?

Unit test succeeds, i.e. variable i has value of 0.905, as https://github.com/Superlokkus/spielwiese/blob/napi_linking_problems_statics/src/lib_name/include/lib_name/lib_name.hpp#L9 Works as intended on Linux.

What do you see instead?

Failing unit test, i.e. apparently no Dynamic initialization of the non local variable, i.e. class instance. ( https://en.cppreference.com/w/cpp/language/initialization#Non-local_variables ) <!-- If possible please provide textual output instead of screenshots. -->

Additional information

This is about on of the wonders of the magic doe execution in C++ binaries before the main() function is called. Bad for people using non local variables which require dynamic initialization (like std::string, std::vector, std::map, often use for big shared constants.

<!-- Tell us anything else you think we should know. --> For the possibility of beeing a cmake-js problem issue https://github.com/cmake-js/cmake-js/issues/205 was created. https://stackoverflow.com/questions/5114683/loading-dll-not-initializing-static-c-classes might be interessting

closed time in 5 days

Superlokkus

issue commentnodejs/node

Initialization code for native node module not called on windows, ie. DLL init missing

Node.js calls LoadLibraryExW() with the LOAD_WITH_ALTERED_SEARCH_PATH flag. Nothing out of the ordinary.

I'm going to close this because I see no indication that it's an issue with Node.js itself. You are the first and so far only one to report this particular behavior. It's likely something on your end.

You're welcome to open an issue in nodejs/help if you have follow-up questions.

Superlokkus

comment created time in 5 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

Ah, like that. I think it only matters at the top level because the stat cache is cleared when control returns to the event loop.

I'm currently looking at a midsize application that has two dozen instances of the above pattern (that I can find) on a total of 1,200 require() calls, so about 2% of the total.

An inexact science benchmark suggests not caching the result makes such require() calls 2.8x slower. That's not as bad as I feared.

There's a caveat though: require() searches upwards, therefore deeper directory structures are penalized more heavily.

benjamingr

comment created time in 6 days

Pull request review commentnodejs/node

dgram: make UDPWrap more reusable

 void UDPWrap::Initialize(Local<Object> target,   Environment* env = Environment::GetCurrent(context);    Local<FunctionTemplate> t = env->NewFunctionTemplate(New);-  t->InstanceTemplate()->SetInternalFieldCount(1);+  t->InstanceTemplate()->SetInternalFieldCount(kUDPWrapBaseField + 1);

This is error prone. Things will break badly when someone changes kUDPWrapBaseField from 1 to 0. Can I suggest this alternative?

class BaseObject {
 public:
  enum InternalFields { kSlot, kCount };
  // ...
};

class AsyncWrap : public BaseObject {
 public:
  enum InternalFields { kCount = BaseObject::InternalFields::kCount };
  // ...
};

// propagating upwards until...

class UDPWrapBase : public HandleWrap {
 public:
  enum InternalFields { kSlot = HandleWrap::InternalFields::kCount, kCount };
  // ...
};

class UDPWrap : public UDPWrapBase {
 public:
  enum InternalFields { kCount = UDPWrapBase::InternalFields::kCount };
  // ...
};

void UDPWrap::Initialize(...) {
  // ...
  t->InstanceTemplate()->SetInternalFieldCount(InternalFields::kCount);
  // ...
}
jasnell

comment created time in 6 days

Pull request review commentnodejs/node

dgram: make UDPWrap more reusable

 void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {     }   } -  uv_buf_t* bufs_ptr = *bufs;-  if (err == 0 && !UNLIKELY(env->options()->test_udp_no_try_send)) {-    err = uv_udp_try_send(&wrap->handle_, bufs_ptr, count, addr);+  if (err == 0) {+    err = wrap->Send(*bufs, count, addr);+  }

No braces. Even easier to read/grep when on a single line.

jasnell

comment created time in 6 days

Pull request review commentnodejs/node

dgram: make UDPWrap more reusable

 void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {     CHECK(args[3]->IsBoolean());   } -  Local<Object> req_wrap_obj = args[0].As<Object>();   Local<Array> chunks = args[1].As<Array>();   // it is faster to fetch the length of the   // array in js-land   size_t count = args[2].As<Uint32>()->Value();-  const bool have_callback = sendto ? args[5]->IsTrue() : args[3]->IsTrue(); -  size_t msg_size = 0;+  wrap->current_send_req_wrap_ = args[0].As<Object>();+  wrap->current_send_has_callback_ =+      sendto ? args[5]->IsTrue() : args[3]->IsTrue();

Looks like those are used to pass up additional data to CreateSendWrap()? Inelegant..

At the very least, they should be moved to right before the Send() call (that's what may or may not call CreateSendWrap(), right?) and cleared right after.

jasnell

comment created time in 6 days

pull request commentnodejs/node

doc: update os.tmpdir() to discuss symlink results on macOS

@fabiosantoscode If you think it's a quirk worth addressing, why don't you petition Apple to move away from symlinks? That would fix it for everyone everywhere.

Trott

comment created time in 6 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

Yes and yes (I think - I'm not completely sure what you mean by "also not at module level/require time".)

benjamingr

comment created time in 6 days

issue commentnodejs/node

Initialization code for native node module not called on windows, ie. DLL init missing

Why are you opening an issue here? Phrased another way: what makes you believe this is an issue with Node.js itself and not your add-on or cmake-js?

Superlokkus

comment created time in 6 days

pull request commentnodejs/node

src: combine internal file read utils

The prevailing style is to omit braces, ergo, new code should omit braces. Consistency trumps personal preference.

devsnek

comment created time in 6 days

issue commentlibuv/help

Compile to WASM

I'm moving this to libuv/help because it's not really an issue with libuv itself.

I suspect the answer to your question is "you're out of luck" - the ability to sleep/suspend by polling on a possibly empty set of file descriptors is central to libuv's design.

femski

comment created time in 6 days

issue commentnodejs/node

repl: printing big strings results in OOM

It should be possible to teach v8::String::Write(), v8::String::WriteUtf8(), etc. to not flatten cons strings when their length exceeds a certain threshold, no new API necessary.

Right now they always call v8::internal::String::Flatten() for ease of use but there's no reason they have to.

There might already be (partial?) support for that in the v8::internal::String::WriteToFlat() helper.

joyeecheung

comment created time in 6 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

That pessimizes a pattern that is fairly common in larger applications:

try {
  var debug = require('debug');  // just an example, of course
} catch (e) {
  var debug = () => {};
}

The bigger the program, the more occurrences of that pattern pop up, and the more it is punished if the results aren't in the stat cache.

benjamingr

comment created time in 6 days

pull request commentnodejs/node

doc: update os.tmpdir() to discuss symlink results on macOS

I'm -.5 on documenting a platform quirk that 99% of the time should be inconsequential.

https://github.com/sindresorhus/temp-write/issues/8 seems to be about writing Node.js code to the temp dir, then loading that with require().

Yes, __filename will be different from what you might naively expect - but take a step back and ask yourself if you're doing something that maybe you shouldn't be doing in the first place.

Trott

comment created time in 6 days

issue closednodejs/node

Proposal: Implament https://www.w3.org/DOM/

<!-- Thank you for suggesting an idea to make Node.js better.

Please fill in as much of the template below as you're able. -->

Is your feature request related to a problem? Please describe. We Will Solve API Incompatiblity Related to Browser Environments

Describe the solution you'd like Implamenting a JSDOM like environment directly into node we could introduce something as easy as a api that takes a url and that gets Rendered Into JSDOM with its own context the DOM with its whole API that also reduces the need for other browser compatible API's that would without this context make no sence.

Describe alternatives you've considered Please describe alternative solutions or features you have considered. The Alternate at present is to run your code in chrome headless to have it isolated and behave like in the browser and later get the results.

https://developers.google.com/web/tools/puppeteer/articles/ssr

closed time in 6 days

frank-dspeed

issue commentnodejs/node

Proposal: Implament https://www.w3.org/DOM/

Thanks for the suggestion but there's zero chance of this happening. You're basically asking to turn node into a browser. I'm going to close this out.

frank-dspeed

comment created time in 6 days

pull request commentnodejs/node

src: combine internal file read utils

Majority rule. I did a quick scan - <insert not exact science warning> - and the braceless variant makes up 60% of the single-line if statements:

# braces
$ find src -name \*.cc | xargs cat | perl -e 'while(<>){s/\s+//g;$i=$.+2 if/^if\(.+\{/;$n++ if/^\}/&&$.==$i}print"$n\n"'
582

# braceless
$ find src -name \*.cc | xargs cat | grep -E 'if \(.+\)' | grep -v '{' | grep -c .
1419

The if statements with braces usually have multi-line else clauses.

devsnek

comment created time in 6 days

pull request commentnodejs/node

src: combine internal file read utils

It's at odds with the house style. Let me turn it around: what's the problem with braceless style?

devsnek

comment created time in 7 days

issue commentnodejs/node

How much is my memory?

Libuv has malloc wrappers that can potentially keep a track of active allocations?

It does, but those only track what libuv itself allocates, which isn't much compared to Node or V8.

An LD_PRELOAD wrapper will let you track all malloc/realloc/posix_memalign/free calls, however.

gireeshpunathil

comment created time in 7 days

pull request commentlibuv/libuv

build: remove support for gyp

I'm a member of the build group and I don't know either. Jenkins' best kept secret. :-/

bnoordhuis

comment created time in 7 days

Pull request review commentlibuv/libuv

Add recvmmsg and sendmmsg support

 static void uv__udp_recvmsg(uv_udp_t* handle) {        handle->recv_cb(handle, nread, &buf, (const struct sockaddr*) &peer, flags);     }+    count--;   }   /* recv_cb callback may decide to pause or close the handle */   while (nread != -1-      && count-- > 0+      && count > 0       && handle->io_watcher.fd != -1       && handle->recv_cb != NULL); } +#if HAVE_MMSG+static void uv__udp_sendmmsg(uv_udp_t* handle) {+  uv_udp_send_t* req;+  struct uv__mmsghdr h[UV__MMSG_MAXWIDTH];+  struct uv__mmsghdr *p;+  QUEUE* q;+  ssize_t npkts;+  size_t pkts;+  size_t i;++  if (QUEUE_EMPTY(&handle->write_queue))+    return;++write_queue_drain:+  for (pkts = 0, q = QUEUE_HEAD(&handle->write_queue);+       pkts < UV__MMSG_MAXWIDTH && q != &handle->write_queue;+       ++pkts, q = QUEUE_HEAD(q)) {+    assert(q != NULL);+    req = QUEUE_DATA(q, uv_udp_send_t, queue);+    assert(req != NULL);++    p = &h[pkts];+    memset(p, 0, sizeof(h[pkts]));
    memset(p, 0, sizeof(*p));

Looks a little more obviously correct to me.

oerdnj

comment created time in 7 days

Pull request review commentlibuv/libuv

Add recvmmsg and sendmmsg support

 static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) {   } } +#if HAVE_MMSG+static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {+  struct sockaddr_in6 peers[UV__MMSG_MAXWIDTH];+  struct iovec iov[UV__MMSG_MAXWIDTH];+  struct uv__mmsghdr msgs[UV__MMSG_MAXWIDTH];+  ssize_t nread;+  uv_buf_t chunk_buf;+  size_t chunks;+  int flags;+  size_t k;++  /* prepare structures for recvmmsg */+  chunks = buf->len / UV__UDP_DGRAM_MAXSIZE;+  if (chunks > ARRAY_SIZE(iov))+    chunks = ARRAY_SIZE(iov);+  for (k = 0; k < chunks; ++k) {+    iov[k].iov_base = buf->base + k * UV__UDP_DGRAM_MAXSIZE;+    iov[k].iov_len = UV__UDP_DGRAM_MAXSIZE;+    msgs[k].msg_hdr.msg_iov = iov + k;+    msgs[k].msg_hdr.msg_iovlen = 1;+    msgs[k].msg_hdr.msg_name = peers + k;+    msgs[k].msg_hdr.msg_namelen = sizeof(peers[0]);+  }++  do+    nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL);+  while (nread == -1 && errno == EINTR);++  if (nread < 1) {+    if (nread == 0 || errno == EAGAIN || errno == EWOULDBLOCK)+      handle->recv_cb(handle, 0, buf, NULL, 0);+    else+      handle->recv_cb(handle, UV__ERR(errno), buf, NULL, 0);+  } else {+    /* count to zero, so the buffer base comes last */+    for (k = nread; k && handle->recv_cb != NULL;) {
    for (k = nread; k > 0 && handle->recv_cb != NULL;) {
oerdnj

comment created time in 7 days

Pull request review commentlibuv/libuv

Add recvmmsg and sendmmsg support

 static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) {   } } +#if HAVE_MMSG+static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {+  struct sockaddr_in6 peers[UV__MMSG_MAXWIDTH];+  struct iovec iov[UV__MMSG_MAXWIDTH];+  struct uv__mmsghdr msgs[UV__MMSG_MAXWIDTH];+  ssize_t nread;+  uv_buf_t chunk_buf;+  size_t chunks;+  int flags;+  size_t k;++  /* prepare structures for recvmmsg */+  chunks = buf->len / UV__UDP_DGRAM_MAXSIZE;+  if (chunks > ARRAY_SIZE(iov))+    chunks = ARRAY_SIZE(iov);+  for (k = 0; k < chunks; ++k) {+    iov[k].iov_base = buf->base + k * UV__UDP_DGRAM_MAXSIZE;+    iov[k].iov_len = UV__UDP_DGRAM_MAXSIZE;+    msgs[k].msg_hdr.msg_iov = iov + k;+    msgs[k].msg_hdr.msg_iovlen = 1;+    msgs[k].msg_hdr.msg_name = peers + k;+    msgs[k].msg_hdr.msg_namelen = sizeof(peers[0]);+  }++  do+    nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL);+  while (nread == -1 && errno == EINTR);++  if (nread < 1) {+    if (nread == 0 || errno == EAGAIN || errno == EWOULDBLOCK)+      handle->recv_cb(handle, 0, buf, NULL, 0);+    else+      handle->recv_cb(handle, UV__ERR(errno), buf, NULL, 0);+  } else {+    /* count to zero, so the buffer base comes last */+    for (k = nread; k && handle->recv_cb != NULL;) {+      k--;+      flags = 0;+      if (msgs[k].msg_hdr.msg_flags & MSG_TRUNC)+        flags |= UV_UDP_PARTIAL;+      if (k != 0)+        flags |= UV_UDP_MMSG_CHUNK;++      chunk_buf = uv_buf_init(iov[k].iov_base, iov[k].iov_len);+      handle->recv_cb(handle,+		      msgs[k].msg_len,+		      &chunk_buf,+		      msgs[k].msg_hdr.msg_name,+		      flags);

Style nit: arguments should line up with the first argument.

oerdnj

comment created time in 7 days

issue closednodejs/node

Segmentation fault in taking a heap snapshot

  • Version: v10.16.3 (we're using nave)
  • Platform: Linux zagent 4.4.0-159-generic #187-Ubuntu SMP Thu Aug 1 16:28:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: http2

I have been making a lot of requests to the service (like in #29902) and after that I send SIGUSR2 to the service process to take heap snapshot. And service crashed with a segmentation fault.

Core was generated by `/var/lib/nave/installed/10.16.3/bin/node --expose-internals --expose-gc --max-h'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000001a66b35 in node::MemoryRetainerNode::MemoryRetainerNode (this=0x6e95f10, tracker=0x7ffc9b58b9e0, retainer=0xb3be530) at ../src/memory_tracker-inl.h:29
29	    v8::Local<v8::Object> obj = retainer_->WrappedObject();
[Current thread is 1 (Thread 0x7f9641872740 (LWP 30235))]
(gdb) bt
#0  0x0000000001a66b35 in node::MemoryRetainerNode::MemoryRetainerNode (this=0x6e95f10, tracker=0x7ffc9b58b9e0, retainer=0xb3be530) at ../src/memory_tracker-inl.h:29
#1  0x0000000001a67185 in node::MemoryTracker::AddNode (this=0x7ffc9b58b9e0, retainer=0xb3be530, edge_name=0x320201e "session") at ../src/memory_tracker-inl.h:263
#2  0x0000000001a6741a in node::MemoryTracker::PushNode (this=0x7ffc9b58b9e0, retainer=0xb3be530, edge_name=0x320201e "session") at ../src/memory_tracker-inl.h:297
#3  0x0000000001a66ff9 in node::MemoryTracker::Track (this=0x7ffc9b58b9e0, retainer=0xb3be530, edge_name=0x320201e "session") at ../src/memory_tracker-inl.h:244
#4  0x0000000001a66ea6 in node::MemoryTracker::TrackField (this=0x7ffc9b58b9e0, edge_name=0x320201e "session", value=0xb3be530, node_name=0x0) at ../src/memory_tracker-inl.h:100
#5  0x0000000001b455a6 in node::http2::Http2Session::Http2Settings::MemoryInfo (this=0xc3588f0, tracker=0x7ffc9b58b9e0) at ../src/node_http2.h:1160
#6  0x0000000001a6701b in node::MemoryTracker::Track (this=0x7ffc9b58b9e0, retainer=0xc3588f0, edge_name=0x0) at ../src/memory_tracker-inl.h:245
#7  0x0000000001a7bcb3 in node::Environment::<lambda(node::BaseObject*)>::operator()(node::BaseObject *) const (__closure=0x7ffc9b58b9d0, obj=0xc3588f0) at ../src/env.cc:718
#8  0x0000000001a7c0de in node::Environment::ForEachBaseObject<node::Environment::BuildEmbedderGraph(v8::Isolate*, v8::EmbedderGraph*, void*)::<lambda(node::BaseObject*)> >(<unknown type in /var/lib/nave/installed/10.16.3/bin/node, CU 0x2f408c, DIE 0x3762f7>) (this=0x7ffc9b591610, iterator=<unknown type in /var/lib/nave/installed/10.16.3/bin/node, CU 0x2f408c, DIE 0x3762f7>)
    at ../src/env-inl.h:856
#9  0x0000000001a7bd2c in node::Environment::BuildEmbedderGraph (isolate=0x64035e0, graph=0x7ffc9b58bbc0, data=0x7ffc9b591610) at ../src/env.cc:719
#10 0x0000000002859880 in v8::internal::HeapProfiler::BuildEmbedderGraph (this=0x6446730, isolate=0x64035e0, graph=0x7ffc9b58bbc0) at ../deps/v8/src/profiler/heap-profiler.cc:94
#11 0x00000000028773df in v8::internal::NativeObjectsExplorer::IterateAndExtractReferences (this=0x7ffc9b58bdf0, filler=0x7ffc9b58bc30) at ../deps/v8/src/profiler/heap-snapshot-generator.cc:2293
#12 0x0000000002878344 in v8::internal::HeapSnapshotGenerator::FillReferences (this=0x7ffc9b58bcf0) at ../deps/v8/src/profiler/heap-snapshot-generator.cc:2516
#13 0x00000000028780b9 in v8::internal::HeapSnapshotGenerator::GenerateSnapshot (this=0x7ffc9b58bcf0) at ../deps/v8/src/profiler/heap-snapshot-generator.cc:2470
#14 0x0000000002859998 in v8::internal::HeapProfiler::TakeSnapshot (this=0x6446730, control=0x0, resolver=0x0) at ../deps/v8/src/profiler/heap-profiler.cc:104
#15 0x0000000001e6a1c5 in v8::HeapProfiler::TakeHeapSnapshot (this=0x6446730, control=0x0, resolver=0x0) at ../deps/v8/src/api.cc:10480
#16 0x00007f9625b4d004 in (anonymous namespace)::WriteSnapshot(v8::FunctionCallbackInfo<v8::Value> const&) () from /var/cache/znpm64/heapdump-0.3.7/build/Release/addon.node
#17 0x0000000001f377d4 in v8::internal::FunctionCallbackArguments::Call (this=0x7ffc9b58d180, handler=0x1782bf8db941) at ../deps/v8/src/api-arguments-inl.h:94
#18 0x0000000001f3a5fa in v8::internal::(anonymous namespace)::HandleApiCallHelper<false> (isolate=0x64035e0, function=..., new_target=..., fun_data=..., receiver=..., args=...)
    at ../deps/v8/src/builtins/builtins-api.cc:109
#19 0x0000000001f384f0 in v8::internal::Builtin_Impl_HandleApiCall (args=..., isolate=0x64035e0) at ../deps/v8/src/builtins/builtins-api.cc:139
#20 0x0000000001f38271 in v8::internal::Builtin_HandleApiCall (args_length=6, args_object=0x7ffc9b58d3a0, isolate=0x64035e0) at ../deps/v8/src/builtins/builtins-api.cc:127
#21 0x000034e86e8c1d64 in ?? ()
#22 0x000034e86e8c1cc1 in ?? ()
#23 0x00007ffc9b58d350 in ?? ()
#24 0x0000000000000006 in ?? ()
#25 0x00007ffc9b58d3e8 in ?? ()
#26 0x000034e86e7a0ab6 in ?? ()
#27 0x00000ccf204026f1 in ?? ()
#28 0x00001782bf8db9d1 in ?? ()
#29 0x0000000600000000 in ?? ()
#30 0x00000ccf20402801 in ?? ()
#31 0x0000034306c9d369 in ?? ()
#32 0x00001e996428d481 in ?? ()
#33 0x00000ccf204022b1 in ?? ()
#34 0x00001782bf8db9d1 in ?? ()
#35 0x000039fb67984a19 in ?? ()
#36 0x0000034306c9d3a1 in ?? ()
#37 0x0000005000000000 in ?? ()
#38 0x000007754167fe01 in ?? ()
#39 0x00001782bf8dba79 in ?? ()
#40 0x00002b96738db5e1 in ?? ()
#41 0x00007ffc9b58d420 in ?? ()
#42 0x000034e86e78f303 in ?? ()
#43 0x0000088e1c58a771 in ?? ()
#44 0x0000000000000000 in ?? ()

in node source code added 2 lines - see https://github.com/nodejs/node/issues/29902#issuecomment-540585168

closed time in 7 days

lomaster1

issue commentnodejs/node

Segmentation fault in taking a heap snapshot

Right, I can see you're using a bunch of add-ons. Odds are > 95% the crash is caused by one of them; ffi (and ref, and ref-struct, etc.) in particular are great at corrupting the JS heap. Try excluding them and see if the crash goes away.

If you can still reproduce without add-ons (heapdump excepted), please post steps to reproduce and I'll take a look.

lomaster1

comment created time in 7 days

pull request commentlibuv/libuv

build: remove support for gyp

Thoughts on how to proceed? The Windows and z/os buildbots are red with this PR.

bnoordhuis

comment created time in 7 days

issue closednodejs/build

ci,libuv: decommission ubuntu1404-gyp-{32,64}

The following jobs can be removed from https://ci.nodejs.org/job/libuv-test-commit/:

  • ubuntu1404-gyp-32
  • ubuntu1404-gyp-64

14.04 is out of support and libuv is about to drop support for gyp so no point in keeping them around.

Refs: https://github.com/libuv/libuv/pull/2682

closed time in 7 days

bnoordhuis

issue commentnodejs/build

ci,libuv: decommission ubuntu1404-gyp-{32,64}

Fixed, closing.

bnoordhuis

comment created time in 7 days

issue commentnodejs/node

Segmentation fault in taking a heap snapshot

Thanks. Do you have any other add-ons besides node-heapdump loaded? What does find node_modules -name \*.node print?

lomaster1

comment created time in 7 days

issue commentnodejs/node

How much is my memory?

Oh, you mean arena allocations. Libuv has no insight into libc's bookkeeping though.

You could write an add-on that calls glibc's mtrace() but at the risk of stating the obvious: that's specific to glibc.

gireeshpunathil

comment created time in 7 days

issue commentnodejs/node

Segmentation fault in taking a heap snapshot

And can you post the output of info files?

lomaster1

comment created time in 7 days

more