-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
message: "Assertion `val->IsArrayBufferView()' failed." #41949
Comments
I'm not sure I understand what the ask here is - to fail with a catchable exception? Something like: diff --git a/lib/string_decoder.js b/lib/string_decoder.js
index 7447bb3f46..ab6bfb306b 100644
--- a/lib/string_decoder.js
+++ b/lib/string_decoder.js
@@ -42,6 +42,7 @@ const {
} = internalBinding('string_decoder');
const internalUtil = require('internal/util');
const {
+ ERR_ILLEGAL_CONSTRUCTOR,
ERR_INVALID_ARG_TYPE,
ERR_UNKNOWN_ENCODING
} = require('internal/errors').codes;
@@ -101,6 +102,9 @@ StringDecoder.prototype.write = function write(buf) {
throw new ERR_INVALID_ARG_TYPE('buf',
['Buffer', 'TypedArray', 'DataView'],
buf);
+ if (!this[kNativeDecoder]) {
+ throw new ERR_ILLEGAL_CONSTRUCTOR();
+ }
return decode(this[kNativeDecoder], buf);
}; |
My intuition is "we shouldn't guard against this sort of thing" most likely. @addaleax wdyt? |
I mean, I personally think that it’s fine to add guards (in C++, not JS, to keep performance parity), but I think that ship has sailed for Node.js internals. |
This makes the function throw an exception from C++ instead of crashing. Fixes: nodejs#41949 Signed-off-by: Darshan Sen <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: nodejs#41949 Signed-off-by: Darshan Sen <[email protected]>
Great, I think this issue can be closed. |
We can keep this issue open for now and it will get closed automatically when any of the PRs land since I have added |
OK Thanks! |
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: #41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
This makes the function throw an exception from JS instead of crashing. Fixes: nodejs#41949 Signed-off-by: Darshan Sen <[email protected]> PR-URL: nodejs#42062 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]>
Version
node-v16.13.2
Platform
Linux astra 4.15.3-141-generic #astra26+ci17 x86_64 GNU/Linux (debian-based)
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Standart buildCompiled with:
gcc (version 8.3.0) ;
Configure params:
--prefix="/target/dir";
Builded binary info:
node: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped.
What is the expected behavior?
No response
What do you see instead?
Stderr with run crafted sample: Abort;
Additional information
Call might be what is causing in type proto (the last dot).
The text was updated successfully, but these errors were encountered: