GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dgram: copy the array when using the list variant in send() by mcollina · Pull Request #6804 · nodejs/node

Conversation

@mcollina

@mcollina mcollina commented May 17, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

dgram

Description of change

This commit fix a possible crash situation in dgram send().
A crash is possible if an array is passed, and then altered after the
send call, as the call to libuv is wrapped in process.nextTick().

This PR slightly slow things down (1-2%) on Mac OS X, let me know if we should do a full performance review.

Fixes: #6616

cc @bnoordhuis @brown-dragon

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added the dgram Issues and PRs related to UDP and the dgram module. label May 17, 2016
@jasnell

jasnell commented May 17, 2016

Copy link
Copy Markdown
Member

LGTM if CI is green.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 17, 2016

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/2675/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 17, 2016

Copy link
Copy Markdown
Member Author

This should be backported to v5.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 19, 2016

Copy link
Copy Markdown
Member Author

There are some failures on freebsd and smartos, I think they are transient, rerunning: https://ci.nodejs.org/job/node-test-pull-request/2697/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented May 19, 2016

Copy link
Copy Markdown
Member

LGTM but bonus points if you also add a fix + regression test for the empty array case. It's okay to do it in a separate commit because it's arguably a separate issue.

Aside: I'm slightly surprised the linter accepts the assign-in-if syntax. But if the linter is okay with it, then I am, too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 19, 2016

Copy link
Copy Markdown
Member Author

@bnoordhuis done, I'm adding an empty buffer if the array is empty, or do you think that throwing will be better?

CI: https://ci.nodejs.org/job/node-test-pull-request/2699/.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed May 19, 2016
View reviewed changes
Comment thread lib/dgram.js Outdated

@bnoordhuis bnoordhuis May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more of a personal preference but can you use buffer.push(...)? That makes it clear we're appending, not replacing, without having to look at the surrounding code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented May 19, 2016

Copy link
Copy Markdown
Member

A small nit about the first commit: the first line of the commit log should be <= 50 characters.

While you're working on send(), can I suggest introducing a local variable called e.g. list? Replacing the buffer argument with the processed result is less clear, IMO.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from c9e6e80 to 09604f8 Compare May 19, 2016 13:33
@mcollina

mcollina commented May 19, 2016

Copy link
Copy Markdown
Member Author

@bnoordhuis update with the nit you asked!

Let me know if you are ok with this, and I'll land it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

santigimeno
santigimeno reviewed May 19, 2016
View reviewed changes
Comment thread test/parallel/test-dgram-send-empty-array.js Outdated

@santigimeno santigimeno May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of the timer?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina May 19, 2016

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It allows fast-failures, otherwise you rely on the 1 minute timeout that each tests has.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@santigimeno santigimeno May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but these kind of timers have been source of flaky tests. I don't think relying in the test runner timeout is a bad idea.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina May 19, 2016

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem are not the timers, UDP messages can get lost: that's why the tests are flaky. If it has not arrived after 200ms (adjusted for platforms), it will never arrive. We might discuss on increasing those timeouts to reduce the likelyhood of missing a "right" message.
There will always be flaky tests on UDP if we want high coverage.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@santigimeno santigimeno May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that: it's UDP.
But I think these kind timers (the test is taking longer than expected so we throw) should only exist when testing timing related features (timers, connection timers, etc.) otherwise the test runner should catch them. I think @Trott made some good points here: nodejs/testing#27 (comment).

Anyway, I'm fine either way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina May 19, 2016

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests of UDP are done in the same way. If we want to change those, we can (and probably we should). It's definite a different PR as this is becoming more and more full of stuff.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@santigimeno santigimeno May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina

mcollina commented May 19, 2016

Copy link
Copy Markdown
Member Author

@santigimeno I've updated the tests.

BTW, should we kick off @nodejs/dgram?

Let me know if anybody would like to change anything else :)

These looks like 4 independent commits, what metadata should I apply to those in the message editing phase?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 19, 2016

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/2702/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed May 19, 2016
View reviewed changes
Comment thread lib/dgram.js Outdated

@bnoordhuis bnoordhuis May 19, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list is a better name for the argument and, arguably, fixBufferList for the function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented May 19, 2016

Copy link
Copy Markdown
Member

There are failures on the OS X and ARM buildbots. The FreeBSD test failure appears to be unrelated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 27e05fb to 05ad943 Compare May 23, 2016 07:12
@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

@bnoordhuis addressed your nits.

new CI: https://ci.nodejs.org/job/node-test-pull-request/2735/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed May 23, 2016
View reviewed changes
Comment thread test/parallel/test-dgram-send-callback-buffer-length.js Outdated

@bnoordhuis bnoordhuis May 23, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.platformTimeout(200)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented May 23, 2016

Copy link
Copy Markdown
Member

LGTM with comment. Was your plan to squash the last two commits into the first two?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

@bnoordhuis I still see 4 commits, or maybe I did some mistake on git and github is not picking that up.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 05ad943 to 4bbdb54 Compare May 23, 2016 08:12
@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/2736/

I did a couple of fix to avoid some flakyness.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 4bbdb54 to 8a3d435 Compare May 23, 2016 08:22
@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

new CI: https://ci.nodejs.org/job/node-test-pull-request/2737/
(test was failing in the previous one)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

new new CI: https://ci.nodejs.org/job/node-test-pull-request/2739/
(sigh, lots of unrelated failures on SmartOS & others :/)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 8a3d435 to bcaa1c9 Compare May 23, 2016 10:09
@mcollina

mcollina commented May 23, 2016

Copy link
Copy Markdown
Member Author

Again with some changes: https://ci.nodejs.org/job/node-test-pull-request/2740/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 24, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@nodejs/build can you please have a look at the 'parallel/test-dgram-send-empty-array ' test in this PR on OS X? I think it should pass, but it is currently failing and I cannot understand why. I've run it thousands of times here and I got zero failures.

This is the last run: https://ci.nodejs.org/job/node-test-commit-osx/3487/nodes=osx1010/tapTestReport/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented May 24, 2016

Copy link
Copy Markdown
Contributor

Any chance that this is nodejs/node-v0.x-archive#8023 resurfacing? You could try removing the skip in https://github.com/nodejs/node/blob/master/test/parallel/test-dgram-empty-packet.js and running the CI on OS X.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 7e1a6c9 to 1b8c3e2 Compare May 24, 2016 17:24
@mcollina

mcollina commented May 24, 2016

Copy link
Copy Markdown
Member Author

@cjihrig it should be it. Maybe the CI box is not running El Capitan?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 1b8c3e2 to 7b65d94 Compare May 24, 2016 17:58
@mcollina

mcollina commented May 24, 2016

Copy link
Copy Markdown
Member Author

Thanks @cjihrig for the support, that was it.

New CI with the fix: https://ci.nodejs.org/job/node-test-pull-request/2770/

cjihrig reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 24, 2016

Copy link
Copy Markdown
Member Author

ci passing, @jasnell @bnoordhuis please give a last pass before I merge.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented May 24, 2016

Copy link
Copy Markdown
Member

LGTM but I only gave it a real quick look-over this time around.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina added 4 commits May 25, 2016 09:35
@mcollina
dgram: copy the list in send
353c6e2
This commit fix a possible crash situation in dgram send().
A crash is possible if an array is passed, and then altered after the
send call, as the call to libuv is wrapped in process.nextTick().

Fixes: nodejs#6616
@mcollina
dgram: support sending an empty array
1059d07
Sending an empty array was crashing in libuv, this commit allocates an
empty buffer to allow sending an empty array.
@mcollina
dgram: renamed buffer -> list in send
0f5f917
nits about variable names and push()
@mcollina
dgram: use common.mustCall and common.platformTimeout in send tests
e1a4eee
Fixes situations were some events were not asserted to be emitted.
Removed some flakyness from tests.
@mcollina
mcollina force-pushed the dgram-multi-buffer-copy branch from 7b65d94 to e1a4eee Compare May 25, 2016 07:45
@mcollina

mcollina commented May 25, 2016

Copy link
Copy Markdown
Member Author

CI after rebase https://ci.nodejs.org/job/node-test-pull-request/2777/ (didn't apply cleanly)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented May 25, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented May 25, 2016

Copy link
Copy Markdown
Member

@mcollina ... saw your question in IRC re: squashing the commits or not.... I would go ahead and squash before landing

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 26, 2016

Copy link
Copy Markdown
Member Author

Landed as c14e98b.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina closed this May 26, 2016
mcollina added a commit that referenced this pull request May 26, 2016
@mcollina
dgram: copy the list in send
c14e98b
This commit fix a possible crash situation in dgram send().
A crash is possible if an array is passed, and then altered after the
send call, as the call to libuv is wrapped in process.nextTick().
It also avoid sending an empty array to libuv by allocating an empty
buffer. It also does some cleanup inside send() to increase readability.

It removes test flakyness by use common.mustCall and
common.platformTimeout. Fixes situations were some events were not
asserted to be emitted.

Fixes: #6616
PR-URL: #6804
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request May 30, 2016
@mcollina @Fishrock123
dgram: copy the list in send
e995e0d
This commit fix a possible crash situation in dgram send().
A crash is possible if an array is passed, and then altered after the
send call, as the call to libuv is wrapped in process.nextTick().
It also avoid sending an empty array to libuv by allocating an empty
buffer. It also does some cleanup inside send() to increase readability.

It removes test flakyness by use common.mustCall and
common.platformTimeout. Fixes situations were some events were not
asserted to be emitted.

Fixes: nodejs#6616
PR-URL: nodejs#6804
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
@mcollina @rvagg
dgram: copy the list in send
8e6f8b2
This commit fix a possible crash situation in dgram send().
A crash is possible if an array is passed, and then altered after the
send call, as the call to libuv is wrapped in process.nextTick().
It also avoid sending an empty array to libuv by allocating an empty
buffer. It also does some cleanup inside send() to increase readability.

It removes test flakyness by use common.mustCall and
common.platformTimeout. Fixes situations were some events were not
asserted to be emitted.

Fixes: #6616
PR-URL: #6804
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 11, 2016
Audit commits not found on v4.x-staging #7661
Closed
@MylesBorins

MylesBorins commented Jul 11, 2016

Copy link
Copy Markdown
Contributor

@mcollina lts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins MylesBorins added the lts-watch-v4.x label Jul 12, 2016
@mcollina

mcollina commented Jul 12, 2016

Copy link
Copy Markdown
Member Author

@thealphanerd this depends on #4374, which hasn't been ported yet. I'm 👍 on both.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

MylesBorins commented Jul 12, 2016

Copy link
Copy Markdown
Contributor

I'm going to assume that #4374 will not land in LTS as it does not increase stability. As such I will label this as don't land for now.
Please feel free to open a backport PR or issue on the LTS repo so the WG can discuss it if you think we should include it in v4.5.0

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins MylesBorins added dont-land-on-v4.x and removed lts-watch-v4.x labels Jul 12, 2016
@mcollina

mcollina commented Jul 12, 2016

Copy link
Copy Markdown
Member Author

I'm neutral, the only reason to have it on the v4 like is to encourage adoption of this API. It's not that useful with support only on v5 and v6. But, I agree with you that it does not increase stability.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

dgram Issues and PRs related to UDP and the dgram module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

dgram: socket.send() crash when input array is modified

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@mcollina @jasnell @bnoordhuis @cjihrig @MylesBorins @santigimeno @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.