-
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
napi_get_buffer_info(): change of behavior in v11.11.0 #26514
Comments
Yeah, that’s definitely possible.
I don’t think we can make guarantees about the contents of
For that a full reproduction would be great, and in particular it’s good to know how you created the Buffer instance? |
Thanks @addaleax
Sure, I don't mind updating the assertions. I would just like to understand the reason for the change. The assertions were helpful to ensure that certain logic had run, especially where some buffer arguments were required and others were optional. For example, in our async work complete handler, before deleting napi_value references, we would assert that the corresponding pointers were in fact defined.
Sure, here's a gist which reproduces exactly on v11.10.0 (passes) and v11.11.0 (fails): https://gist.github.com/jorangreef/19956b854e7d5e245c8ecb9eb655f4cd
Here, if the addon prints Really appreciate your help with this. |
I think this is a result of the added |
Thanks @addaleax |
Just out of interest, but perhaps this change of behavior will cause some ecosystem breakage? For example, I updated our native addon's assertions to And I would have thought this would have been enough. However, our fuzz tests picked up strange behavior when instantiating an hmac using OpenSSL. Technically, an hmac can be instantiated with an empty key, however 84e02b1#diff-801e3948990f4965a8ea4aca4a423864R4002 now means that it's possible for NULL to be passed to OpenSSL, which sees this and fails the initialization. |
It looks like its turtles all the way down. 🐢 |
Instead of |
This fixes issues in which APIs that accept pointers created this way treat `nullptr` and a zero-length buffer differently. We already do something similar for our `Malloc()` implementation. Fixes: nodejs#26514
@jorangreef Okay, I’ve opened #26731 to address this. |
Thanks for fixing this quickly. |
This fixes issues in which APIs that accept pointers created this way treat `nullptr` and a zero-length buffer differently. We already do something similar for our `Malloc()` implementation. PR-URL: nodejs#26731 Fixes: nodejs#26514 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This fixes issues in which APIs that accept pointers created this way treat `nullptr` and a zero-length buffer differently. We already do something similar for our `Malloc()` implementation. PR-URL: #26731 Fixes: #26514 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
A subtle change of behavior in
napi_get_buffer_info()
was introduced in v11.11.0.For v11.10.0 and earlier, the following napi addon's assertions passed, even when the argv buffer value being retrieved was 0 bytes in length.
Since v11.11.0, however, the
assert(*buffer != NULL);
assertion below fails when the argv buffer value is 0 bytes in length.This may not be a deal-breaker, and perhaps we need to update our assertions, but I first wanted to get to the bottom of why exactly this is happening, and why this changed in v11.11.0.
@addaleax, I know you did some recent work in #26301, could that have anything to do with this?
The text was updated successfully, but these errors were encountered: