-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
dns: fix empty elem in result array #3696
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined value. That's because initialization of v8::Array pre-allocate entries for all linked-list nodes, but we may actually some of them after the 2 while loops.
This fixes intermittent failure of test/internet/test-dns-ipv6.js caused by assertion failure on line 168. ips.forEach(function(ip) {
assert.ok(isIPv6(ip.address), // failing assertion
'Invalid IPv6: ' + ip.address.toString());
assert.strictEqual(ip.family, 6);
}); I observed that the ip.address is undefined. then I try to print out the whole ips, and found this output:
then I try to print out the parameter "addresses" in onlookupall in lib/dns.js:
|
LGTM, but I'd like the input of someone more familiar with that part of the code base. Are we going to take a hit somewhere by not passing |
@cjihrig btw, the default length passing to Array::New is 0. |
If there is some concern with not passing a larger default length, can we remove the entries that have an undefined address after the fact ? |
Seems like a question @trevnorris might know the answer to. Is it likely faster to create a larger array up front and then remove undefined values, or build the array as needed? It may also depend on how common |
@cjihrig undefined value is a special double representation (8 bytes). |
@mhdawson allocating a larger array and then removing entries would increase internal fragmentation. It may not benefit performance. |
Without testing, I would say each are equally fast or slow. Wouldn't worry about that amount of possible performance gain here. |
In that case, I'd say this is fine as long as the CI is happy. |
@trevnorris absolutely agree. |
LGTM, this is not performance critical. At least, not so critical that specifying the length upfront makes a difference. |
Hello, can someone merge this in? It has been 4 days now. :) |
@john-yan .. there were some failures in the CI on freebsd. They look unrelated but can you please take a look and confirm. |
@jasnell Hello, the failures show some native modules not found. They should be unrelated. |
Yes, this looks like it should be fine. Landing. |
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Thanks! Landed in 19bf72d |
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: nodejs/node#3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
landed in v4.x-staging in a632db5 |
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When getaddrinfo linked-list results contain entries other than AF_INET and AF_INET6, the resulting v8::Array will contain undefined values. That's because initialization of v8::Array pre-allocates entries for all linked-list nodes, but not all of them will be in the final results. This commit ensures that the array only contains valid results. PR-URL: #3696 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When getaddrinfo linked-list results contain entries other than AF_INET
and AF_INET6, the resulting v8::Array will contain undefined value.
That's because initialization of v8::Array pre-allocate entries for all
linked-list nodes, but we may actually some of them after the 2 while
loops.