Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix vector subscript out of range #18460

Closed
wants to merge 1 commit into from

Conversation

apapirovski
Copy link
Member

It appears that #18291 broke debug builds on Windows. This should resolve the issue.

@tniessen is currently running a test. If anyone else can try a Windows debug build with this patch applied, that would be appreciated.

Fixes: #18459

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

src

@apapirovski apapirovski added c++ Issues and PRs that require attention from people who are familiar with C++. fast-track PRs that do not need to wait for 48 hours to land. labels Jan 30, 2018
@apapirovski apapirovski requested a review from tniessen January 30, 2018 18:38
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 30, 2018
@apapirovski
Copy link
Member Author

Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

Tests pass: https://ci.nodejs.org/job/node-test-commit-light/196/
This seems to solve the problem. Thanks for the quick fix @apapirovski!

@tniessen
Copy link
Member

It would be great if someone else from @nodejs/platform-windows could confirm that this indeed fixes the issue before fast-tracking this.

@apapirovski
Copy link
Member Author

/cc @addaleax @jasnell

@@ -1002,7 +1002,9 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
} else {
std::vector<Local<Value>> args(1 + argc);
args[0] = callback;
std::copy(&argv[0], &argv[argc], &args[1]);
Copy link
Member

Choose a reason for hiding this comment

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

You could replace &args[1] with &args.data()[1] to get rid of the conditional.

(It's legal to create a pointer that points one element beyond the array as long as you don't dereference it - which won't happen if argc == 0 because there won't be elements to copy.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better: replace it with args.begin() + 1, since std::copy works with iterators.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, updated now. Thanks for the feedback.

Copy link
Contributor

@seishun seishun left a comment

Choose a reason for hiding this comment

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

Please use either mine or @bnoordhuis's suggestion to avoid the conditional.

@apapirovski
Copy link
Member Author

@apapirovski
Copy link
Member Author

Landed in 332b56c

@apapirovski apapirovski deleted the fix-18459 branch January 31, 2018 14:36
apapirovski added a commit that referenced this pull request Jan 31, 2018
PR-URL: #18460
Fixes: #18459
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Nikolai Vavilov <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 20, 2018
PR-URL: #18460
Fixes: #18459
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Nikolai Vavilov <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
PR-URL: #18460
Fixes: #18459
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Nikolai Vavilov <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
PR-URL: #18460
Fixes: #18459
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Nikolai Vavilov <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 21, 2018
@MylesBorins
Copy link
Contributor

Needs to land if we backport #18291

MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
PR-URL: nodejs#18460
Fixes: nodejs#18459
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Nikolai Vavilov <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. fast-track PRs that do not need to wait for 48 hours to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug assertion fails on Windows
8 participants