Uh oh!
There was an error while loading. Please reload this page.
src: add ERR_* helpers in C++ and migrates toString() errors in string_bytes.cc - #19739
src: add ERR_* helpers in C++ and migrates toString() errors in string_bytes.cc#19739joyeecheung wants to merge 2 commits into
Conversation
joyeecheung
commented
Apr 2, 2018
cc @addaleax |
joyeecheung
commented
Apr 2, 2018
There was a problem hiding this comment.
This should also be the overload that takes a context argument :)
joyeecheung
commented
Apr 4, 2018
Replace the deprecated API with the one that takes the context per suggestion by @addaleax , thanks! |
Looks like on Linux PPCBE we need to ensure an extra copy of memory available for reordering..fixed the test. EDIT: the usage of |
a9fc7b5 to
b416589CompareCurrently calling StringBytes::Encode on a UCS2 buffer results in two copies of the buffer and the usage of std::vector::assign makes the memory usage unpredictable, and therefore hard to test against. This patch makes the memory usage more predictable by allocating the memory using node::UncheckedMalloc and handles the memory allocation failure properly. Only one copy of the buffer will be created and it will be freed upon GC of the string. PR-URL: #19798 Refs: #19739 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit adds node::ERR_*(isolate, message) helpers in the C++ land to assign error codes to existing C++ errors. The following errors are added: - ERR_MEMORY_ALLOCATION_FAILED - ERR_STRING_TOO_LARGE
joyeecheung
commented
Apr 7, 2018
Landed in 1f29963...63eb267, thanks! |
This commit adds node::ERR_*(isolate, message) helpers in the C++ land to assign error codes to existing C++ errors. The following errors are added: - ERR_MEMORY_ALLOCATION_FAILED - ERR_STRING_TOO_LARGE PR-URL: #19739Fixes: #3175Fixes: #9489 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
The old error name and message were trying to be consistent with ERR_BUFFER_TOO_LARGE but they were not really accurate. The kStringMaxLength was measured in number of characters, not number of bytes. The name ERR_STRING_TOO_LARGE also seems a bit awkward. This patch tries to correct them before they get released to users. PR-URL: nodejs#19864 Refs: nodejs#19739 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Currently calling StringBytes::Encode on a UCS2 buffer results in two copies of the buffer and the usage of std::vector::assign makes the memory usage unpredictable, and therefore hard to test against. This patch makes the memory usage more predictable by allocating the memory using node::UncheckedMalloc and handles the memory allocation failure properly. Only one copy of the buffer will be created and it will be freed upon GC of the string. PR-URL: #19798 Refs: #19739 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Another take of #19465 , this one puts the ERR_* helpers in the node namespace and put them inside node_errors.h instead of mingle them with the environment code.
Also fixes the long-standing issue of error messages in
buf.toStringfailures by migrating them to the new error system.The first commit is taken from #19738
Fixes: #3175
Fixes: #9489
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes