-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
oom/core dump in repl with buffer property tab completion #3136
Comments
Pretty sure the issue is from the following in function filteredOwnPropertyNames(obj) {
if (!obj) return [];
return Object.getOwnPropertyNames(obj).filter(intFilter);
} As can be demonstrated by the following:
|
Could this be why there are ton of these issues reported on git hub with version 4.0+? CALL_AND_RETRY_LAST Allocation failed - process out of memory I'm getting random reports for some internal tools we use and haven't been able to pin point what causes it. It is scary if its related to inspecting properties that are buffers...especially using tools like gulp (where we are seeing all the issues) that have pass buffers around all the time... |
@harry8525 Since Buffers are now iterable, it would be possible to run through the list of all properties and remove any that are indices. Would probably crawl, but at least it wouldn't die. |
I just ran into this using winston + repl: trailsjs/trailpack-repl#20 Logging a small-ish object works fine. If I try to log a larger object (a couple dozen ES6 classes) it fails. |
I'm investigating the issue. |
Edit: Seems I was mistaken: @trevnorris Original:
|
So the issue has to do with I've tried replacing this line with more memory efficient custom code, and succeeded with Any advice is welcome. |
@JordanMajd There is currently no good way to do that. Presumably V8 would need to grow a C++ API that either lets you iterate over non-enumerable properties, or fails gracefully when creating the property name array fails (by creating an empty handle.) Node would then need to be updated to make use of this new API. |
Thanks @bnoordhuis, Follow up question, does tab completion need to have nonenumerable properties? If it doesn't, I already have a working solution for only tab completing enumerable properties. |
I'd say so. For example, methods are normally non-enumerable; only considering enumerable properties would break completion for |
Great point, I had forgotten that methods were non-enumerable. If anyone has advice on where to go from here I am all ears. Otherwise it would seem this issue is not going to be resolved anytime in the near future. |
How about to do eg. function filteredOwnPropertyNames(obj) {
if (!obj) return [];
if (obj instanceof Buffer && obj.length > 1000) {
return Object.getOwnPropertyNames(new Buffer(1)).filter(intFilter);
}
return Object.getOwnPropertyNames(obj).filter(intFilter);
} and then do |
If the buffer or array is too large to completion, make a dummy smallest substitute object for it and emit a warning. Fixes: nodejs#3136
If the buffer or array is too large to completion, make a dummy smallest substitute object for it and emit a warning. PR-URL: #13817 Fixes: #3136 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
If the buffer or array is too large to completion, make a dummy smallest substitute object for it and emit a warning. PR-URL: #13817 Fixes: #3136 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
If the buffer or array is too large to completion, make a dummy smallest substitute object for it and emit a warning. PR-URL: #13817 Fixes: #3136 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
Noticed with a sufficiently large Buffer (or ArrayBuffer) tab completion in the repl will crash the process with out of memory + core dump
The text was updated successfully, but these errors were encountered: