| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@ryzokuken build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/438/pipeline |
Sorry, something went wrong.
There was a problem hiding this comment.
I think you can use .As<Uint32>() for both arguments here. They are coerced in JS with value >>> 0.
Sorry, something went wrong.
There was a problem hiding this comment.
nit: add using v8::Uint32; at the top of the namespace.
Sorry, something went wrong.
There was a problem hiding this comment.
Also, if you are sure this is a Uint32, modify the CHECK above to IsUint32
Sorry, something went wrong.
There was a problem hiding this comment.
Do we need to throw an error here?
Sorry, something went wrong.
There was a problem hiding this comment.
ditto
Sorry, something went wrong.
There was a problem hiding this comment.
This value is not verified in JS
Sorry, something went wrong.
|
Ping. This is ready for review. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Fwiw, I still find it easier to read when using the return-on-error style rather than an if (success) { … } block
Sorry, something went wrong.
There was a problem hiding this comment.
Me too. Fixed.
Sorry, something went wrong.
Sorry, something went wrong.
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only).
|
It looks like the value is not always an integer... let me check |
Sorry, something went wrong.
|
I'm lost here... It seems to me that start and end are guaranteed to be uint32. I added this just before the binding is called: process._rawDebug(`${start}, ${end}`);`Last few lines of output: 16, 32
0, 10
0, 10
./node[25340]: ../src/node_buffer.cc:572:void node::Buffer::{anonymous}::Fill(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `args[2]->IsUint32()' failed.
Here is the relevant code: Lines 869 to 888 in 59e5a39 |
Sorry, something went wrong.
|
Here is the failing block: node/test/parallel/test-buffer-fill.js Lines 320 to 325 in 59e5a39 |
Sorry, something went wrong.
|
I don’t know if it’s relevant, but there seems to be a bunch of compiler warnings from this PR: ../src/node_zlib.cc: In static member function ‘static void node::{anonymous}::ZCtx::Init(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_zlib.cc:471:119: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
CHECK((strategy == Z_FILTERED || strategy == Z_HUFFMAN_ONLY ||
^
In file included from ../src/node_zlib.cc:23:0:
../src/node_buffer.h: In static member function ‘static void node::{anonymous}::ZCtx::Write(const v8::FunctionCallbackInfo<v8::Value>&) [with bool async = true]’:
../src/node_buffer.h:75:3: warning: ‘out_off’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (off > max)
^~
../src/node_zlib.cc:174:28: note: ‘out_off’ was declared here
size_t in_off, in_len, out_off, out_len;
^~~~~~~
In file included from ../src/node_zlib.cc:23:0:
../src/node_buffer.h:79:3: warning: ‘out_len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (max - off < len)
^~
../src/node_zlib.cc:174:37: note: ‘out_len’ was declared here
size_t in_off, in_len, out_off, out_len;
^~~~~~~
../src/node_zlib.cc: In static member function ‘static void node::{anonymous}::ZCtx::Init(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_zlib.cc:471:85: warning: ‘strategy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
CHECK((strategy == Z_FILTERED || strategy == Z_HUFFMAN_ONLY ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
../src/node_zlib.cc:469:14: note: ‘strategy’ was declared here
uint32_t strategy;
^~~~~~~~
In file included from ../src/node_zlib.cc:23:0:
../src/node_buffer.h: In static member function ‘static void node::{anonymous}::ZCtx::Write(const v8::FunctionCallbackInfo<v8::Value>&) [with bool async = false]’:
../src/node_buffer.h:75:3: warning: ‘out_off’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (off > max)
^~
../src/node_zlib.cc:174:28: note: ‘out_off’ was declared here
size_t in_off, in_len, out_off, out_len;
^~~~~~~
In file included from ../src/node_zlib.cc:23:0:
../src/node_buffer.h:79:3: warning: ‘out_len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (max - off < len)
^~
../src/node_zlib.cc:174:37: note: ‘out_len’ was declared here
size_t in_off, in_len, out_off, out_len;
^~~~~~~
|
Sorry, something went wrong.
|
@targos I think this is the failing block: node/test/parallel/test-buffer-fill.js Lines 327 to 330 in 59e5a39 |
Sorry, something went wrong.
|
@addaleax Haha of course, thanks! I think I completely forgot to run the tests locally on this PR (even before making my own changes), sorry. This should be fixed now. |
Sorry, something went wrong.
There was a problem hiding this comment.
Still LGTM :)
Sorry, something went wrong.
| Environment* env = ctx->env(); | ||
| Local<Context> context = env->context(); | ||
|
|
||
| unsigned int flush; |
There was a problem hiding this comment.
I guess CI is going to tell us whether it’s a real problem, but at least in theory this would be uint32_t, too
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
Though perhaps it's worth adding a macro for converting to uint32?
something like (not sure for the exact macro as I don't have a lot of experience with them and they are quite tricky)
#define CHECKED_TO_UINT32(ctx, from, variable) \
uint32_t variable; \
if (!(from)->Uint32Value((ctx)).To(&variable)) return;
CHECKED_TO_UINT32(ctx, args[2], start);(Though this is not needed if we go with FromMaybe version)
Sorry, something went wrong.
| uint32_t start; | ||
| if (!args[2]->Uint32Value(ctx).To(&start)) return; | ||
| uint32_t end; | ||
| if (!args[3]->Uint32Value(ctx).To(&end)) return; |
There was a problem hiding this comment.
Not sure but perhaps FromMaybe version is clearer?
uint32_t start = args[2]->Uint32Value(ctx).FromMaybe(0);
uint32_t end = args[3]->Uint32Value(ctx).FromMaybe(0);Though this will result in function actually continuing execution if provided with invalid value (but wasn't this how it was before - Uint32Value() returns 0 on invalid values AFAIK? )?
Sorry, something went wrong.
There was a problem hiding this comment.
Though this will result in function actually continuing execution if provided with invalid value
That is the previous behaviour, which is buggy in that it will swallow exceptions if both calls fail.
Sorry, something went wrong.
There was a problem hiding this comment.
🤔 shouldn't this then be semver-major to avoid possible breakage?
Also, perhaps we can
if (!args[2]->IsUint32() || !args[3]->IsUint32())
return args.GetReturnValue().Set(-2);
uint32_t start = args[2].As<Uint32>()->Value();
uint32_t end = args[3].As<Uint32>()->Value();in this case (tests seem to pass)?
Sorry, something went wrong.
There was a problem hiding this comment.
The only place where we pass in invalid arguments is from a process.binding() test. We could/should probably remove that test in a follow-up PR, and revert 05aa50f (which is pretty close to your suggestion)
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I thought that this was expected somewhere else, therefore the test. The suggested commit is even better, with the above I wanted to somehow mitigate that test.
Sorry, something went wrong.
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). PR-URL: #22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: nodejs#22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). PR-URL: #22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). PR-URL: #22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Remove all calls to deprecated v8 functions (here: Value::Uint32Value) inside the code (src directory only). PR-URL: #22143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
| Back | FazBrowse Home | New Git URL |
Remove all calls to deprecated v8 functions (here:
Value::Uint32Value) inside the code (src directory only).
Checklist
/cc @addaleax @hashseed