-
Notifications
You must be signed in to change notification settings - Fork 30k
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: Check for overflow when resizing AliasedBufferBase #31740
Conversation
There are some tests that verify hard crashes in |
Had a look into |
@amdoku Yes, ideally a regression test comes with the bugfix itself, so having it in this PR would be perfect 👍 |
@addalex I've added the tests and made sure they pass (on linux at least).
I have found This leads me to believe that the test does not actually assert the overflow behaviour but some other error. Yet after staring and rewriting the code I can not see the error. |
@amdoku Yeah, this should never exit with exit code |
When resizing an aliased_buffer check if the new size will overflow.
@addaleax I have fixed the problem where the test would not abort correctly. I am very unsure about all the modifications in the build files, especially if I have added the targets in all the required places.
|
Added native extension similar to test/addons/stringbytes-external-exceeded-max. Added an abort test to regression test the non overflow behaviour.
The Aliased*Array overflow check test introduced a dependency to a compiled artifact. Add this artifact to the build process in a similar fashion as test/addons and test/js-native-api do.
When resizing an aliased_buffer check if the new size will overflow. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Added native extension similar to test/addons/stringbytes-external-exceeded-max. Added an abort test to regression test the non overflow behaviour. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The Aliased*Array overflow check test introduced a dependency to a compiled artifact. Add this artifact to the build process in a similar fashion as test/addons and test/js-native-api do. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 575b4e3...e08ac09, thanks for the PR! 🎉 |
When resizing an aliased_buffer check if the new size will overflow. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Added native extension similar to test/addons/stringbytes-external-exceeded-max. Added an abort test to regression test the non overflow behaviour. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The Aliased*Array overflow check test introduced a dependency to a compiled artifact. Add this artifact to the build process in a similar fashion as test/addons and test/js-native-api do. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
`cp test/addons/.gitignore test/abort/.gitignore`, because the new addon test in there leaves a build/ folder lying around and somebody is bound to use `git add .` earlier or later. Refs: nodejs#31740
I missed this the first time round but the test added in the PR isn't currently being run because the test configuration for the abort tests doesn't find it.
We can try out the test with a quick hack (we currently don't have a test configuration that mixes addons-style tests and non-addons style tests so this hack excludes the non-addons style abort tests): diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py
index c89ab6e..8a86b1e 100644
--- a/test/testpy/__init__.py
+++ b/test/testpy/__init__.py
@@ -156,7 +156,7 @@ class AddonTestConfiguration(SimpleTestConfiguration):
SimpleTestCase(tst, file_path, arch, mode, self.context, self, self.additional_flags))
return result
-class AbortTestConfiguration(SimpleTestConfiguration):
+class AbortTestConfiguration(AddonTestConfiguration):
def __init__(self, context, root, section, additional=None):
super(AbortTestConfiguration, self).__init__(context, root, section,
additional) which results in:
whoops, so a fixup: diff --git a/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js b/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-o
index 33cd212..eaed311 100644
--- a/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js
+++ b/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js
@@ -1,5 +1,5 @@
'use strict';
-const common = require('../common');
+const common = require('../../common');
const assert = require('assert');
const cp = require('child_process');
Thoughts on how to proceed? Should we revert this as it doesn't have a working test? |
@richardlau I wouldn’t revert the changes to |
I've managed to fix up the test and get it running as part of the CI (I think, at least it works for me locally): #32626 |
nodejs#31740 added an addon-style test to `test/abort` that was never run because `test/abort/testcfg.py` uses the AbortTestConfiguration which inherits from SimpleTestConfiguration which only finds tests in the root of `test/abort`. Make AbortTestConfiguration inherit from AddonTestConfiguration and change AddonTestConfiguration to find the tests in the root of the test bucket in addition to the subfolders. Fixup `test-abort-aliased-buffer-overflow` so that it works as intended. Signed-off-by: Richard Lau <riclau@uk.ibm.com>
`cp test/addons/.gitignore test/abort/.gitignore`, because the new addon test in there leaves a build/ folder lying around and somebody is bound to use `git add .` earlier or later. Refs: #31740 PR-URL: #32624 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`cp test/addons/.gitignore test/abort/.gitignore`, because the new addon test in there leaves a build/ folder lying around and somebody is bound to use `git add .` earlier or later. Refs: #31740 PR-URL: #32624 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`cp test/addons/.gitignore test/abort/.gitignore`, because the new addon test in there leaves a build/ folder lying around and somebody is bound to use `git add .` earlier or later. Refs: #31740 PR-URL: #32624 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When resizing an aliased_buffer check if the new size will overflow. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Added native extension similar to test/addons/stringbytes-external-exceeded-max. Added an abort test to regression test the non overflow behaviour. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The Aliased*Array overflow check test introduced a dependency to a compiled artifact. Add this artifact to the build process in a similar fashion as test/addons and test/js-native-api do. PR-URL: #31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
`cp test/addons/.gitignore test/abort/.gitignore`, because the new addon test in there leaves a build/ folder lying around and somebody is bound to use `git add .` earlier or later. Refs: #31740 PR-URL: #32624 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This reverts commit babeb58. PR-URL: nodejs#33196 Refs: nodejs#31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This reverts commit e08ac09. PR-URL: nodejs#33196 Refs: nodejs#31740 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
When resizing an
AliasedBufferBase
check if the new size will overflow.Creating a new
AliasedBufferBase
the constructor checks if the calculated size in bytes has overflown.When reserving/resizing an existing buffer, the calculated new size in bytes is not checked if it has overflown.
I would want to write tests for this, but as failing the check will call
node::Abort()
I currently do not see how this is possible. I am open for input though.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes