Title: Crash in AddressToJS for udp6 socket bound to link-local address · Issue #41500 · nodejs/node · GitHub
Open Graph Title: Crash in AddressToJS for udp6 socket bound to link-local address · Issue #41500 · nodejs/node
X Title: Crash in AddressToJS for udp6 socket bound to link-local address · Issue #41500 · nodejs/node
Description: Version v17.3.1 Platform Linux darkk-ya-laptop 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem dgram What steps will reproduce the bug? Use the following four files to build the tes...
Open Graph Description: Version v17.3.1 Platform Linux darkk-ya-laptop 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem dgram What steps will reproduce the bug? Use t...
X Description: Version v17.3.1 Platform Linux darkk-ya-laptop 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem dgram What steps will reproduce the bug? Use t...
Opengraph URL: https://github.com/nodejs/node/issues/41500
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash in AddressToJS for udp6 socket bound to link-local address","articleBody":"### Version\n\nv17.3.1\n\n### Platform\n\nLinux darkk-ya-laptop 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux\n\n### Subsystem\n\ndgram\n\n### What steps will reproduce the bug?\n\nUse the following four files to build the test-case:\r\n\r\n\r\n- `dgram-udp6-address.js`:\r\n```js\r\n'use strict';\r\n\r\nconst dgram = require('dgram');\r\nconst socket = dgram.createSocket({ type: 'udp6' });\r\n\r\nconst discard_port = 9;\r\nconst global_ipv6 = '2600::';\r\n\r\n// It might be rejected if there is no route to the ip (e.g. IPv4-only network).\r\nsocket.connect(discard_port, global_ipv6, err => {\r\n if (err === undefined) {\r\n console.log('remoteAddress: ', socket.remoteAddress());\r\n // The next line triggers assertion under certain conditions:\r\n // node[631]: ../src/tcp_wrap.cc:354:v8::Local\u003cv8::Object> node::AddressToJS(node::Environment*, const sockaddr*, v8::Local\u003cv8::Object>): Assertion `(r) == (0)' failed.\r\n console.log('address: ', socket.address());\r\n } else {\r\n console.log('UDP connection error', err);\r\n }\r\n socket.unref();\r\n});\r\n```\r\n\r\n- `Dockerfile`:\r\n```Dockerfile\r\nFROM node:17-bullseye\r\n\r\nRUN set -ex \\\r\n && apt-get update \\\r\n && apt-get install -y --no-install-recommends iproute2 \\\r\n && :\r\n\r\nCOPY --chown=0:0 \\\r\n dgram-udp6-address.js \\\r\n test.sh \\\r\n /\r\n```\r\n\r\n- `test.sh`:\r\n```bash\r\n#!/bin/bash\r\n\r\nset -ex\r\n\r\nip link add dummy0 type dummy\r\nip link set dummy0 up\r\nip -6 address add fe80::aaaa:bbbb:cccc:dddd dev dummy0\r\nip -6 route add default dev dummy0\r\nip addr\r\nip -6 route\r\nnode --version\r\nnode /dgram-udp6-address.js\r\n```\r\n\r\n- `run.sh`:\r\n```bash\r\n#!/bin/bash\r\n\r\nset -ex\r\n\r\ntar cz Dockerfile dgram-udp6-address.js test.sh | docker build -t dgram-udp6-address:latest -\r\n\r\nexec docker run --rm --tty -i \\\r\n --privileged \\\r\n --net=none \\\r\n --sysctl net.ipv6.conf.all.disable_ipv6=0 \\\r\n dgram-udp6-address:latest \\\r\n /bin/bash /test.sh\r\n```\r\n\r\nThe test-case is run with `./run.sh`.\n\n### How often does it reproduce? Is there a required condition?\n\nIt's 100% reproducible with this network set-up.\r\n\r\nThis network setup simulates the **default** setup of Rostelecom ISP in St. Petersburg regarding their handling of IPv6 as seen by my Ubuntu 16.04 laptop:\r\n- the ISP-provided router announces a default gateway via link-local address `fe80::1`\r\n- local machines get link-local address\r\n- no real IPv6 connectivity is provided\r\n- the router responds with `ICMP6, destination unreachable, unreachable route` to IPv6 packets with global destination\n\n### What is the expected behavior?\n\n`node` should not crash whole app. It should rather be some kind of exception, socket error or something like that.\r\n\r\nI've noticed the behavior while developing Electron app, whole app was terminated on `socket.address()` call.\n\n### What do you see instead?\n\n```\r\n...\r\n+ node /dgram-udp6-address.js\r\nremoteAddress: { address: '2600::', family: 'IPv6', port: 9 }\r\nnode[15]: ../src/tcp_wrap.cc:372:v8::Local\u003cv8::Object> node::AddressToJS(node::Environment*, const sockaddr*, v8::Local\u003cv8::Object>): Assertion `(r) == (0)' failed.\r\n 1: 0xb2c330 node::Abort() [node]\r\n 2: 0xb2c3ae [node]\r\n 3: 0xc1da97 node::AddressToJS(node::Environment*, sockaddr const*, v8::Local\u003cv8::Object>) [node]\r\n 4: 0xc2f2ad void node::GetSockOrPeerName\u003cnode::UDPWrap, &uv_udp_getsockname>(v8::FunctionCallbackInfo\u003cv8::Value> const&) [node]\r\n 5: 0xd798de [node]\r\n 6: 0xd7acff v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]\r\n 7: 0x162fff9 [node]\r\n/test.sh: line 12: 15 Aborted (core dumped) node /dgram-udp6-address.js\r\n```\n\n### Additional information\n\nOther affected versions are v12.22.8, v14.18.2, v16.13.1\r\n\r\nRelevant `strace` snippet is:\r\n\r\n```\r\nsocket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 17\r\nbind(17, {sa_family=AF_INET6, sin6_port=htons(0), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, \"::\", &sin6_addr), sin6_scope_id=0}, 28) = 0\r\nconnect(17, {sa_family=AF_INET6, sin6_port=htons(9), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, \"2600::\", &sin6_addr), sin6_scope_id=0}, 28) = 0\r\ngetpeername(17, {sa_family=AF_INET6, sin6_port=htons(9), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, \"2600::\", &sin6_addr), sin6_scope_id=0}, [128->28]) = 0\r\n\r\nremoteAddress: { address: '2600::', family: 'IPv6', port: 9 }\r\n\r\ngetsockname(17, {sa_family=AF_INET6, sin6_port=htons(44890), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, \"fe80::aaaa:bbbb:cccc:dddd\", &sin6_addr), sin6_scope_id=0}, [128->28]) = 0\r\naccess(\"/proc/net\", R_OK) = 0\r\naccess(\"/proc/net/unix\", R_OK) = 0\r\nsocket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 20\r\nioctl(20, SIOCGIFNAME, {ifr_index=0}) = -1 ENODEV (No such device)\r\nclose(20) = 0\r\ngetpid() = 18\r\n\r\nnode[18]: ../src/tcp_wrap.cc:372:v8::Local\u003cv8::Object> node::AddressToJS(node::Environment*, const sockaddr*, v8::Local\u003cv8::Object>): Assertion `(r) == (0)' failed.\r\n```\r\n\r\nSo, the kernel returns `sin6_flowinfo=htonl(0)` for the bound socket, so the assertion is false.\r\n\r\n#39143 seems to be a similar issue on AIX.","author":{"url":"https://github.com/darkk","@type":"Person","name":"darkk"},"datePublished":"2022-01-13T13:56:15Z","url":"https://github.com/nodejs/node/issues/41500"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:47426ff2-a639-0a54-c97c-284b998ea6df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8FA:143C91:D07497:115523C:6AED3F7A |
| html-safe-nonce | a2fb9dec59d567ea4090aee818206c062bc0d6f60e743d5dbd75d5ca053aab36 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEZBOjE0M0M5MTpEMDc0OTc6MTE1NTIzQzo2QUVEM0Y3QSIsInZpc2l0b3JfaWQiOiIzMjcwODgzOTAyODUwMTU0MzYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d0e2d18ec944153af18f74c2551ac536fd5e2bd501c6132c95d94686b24a5596 |
| hovercard-subject-tag | issue:1101779809 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/41500/issue_layout |
| twitter:image | https://opengraph.githubassets.com/03504a46e17e03478024ef00619a587636bdc6aaf62ba23602fae8b5f176b84d/nodejs/node/issues/41500 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/03504a46e17e03478024ef00619a587636bdc6aaf62ba23602fae8b5f176b84d/nodejs/node/issues/41500 |
| og:image:alt | Version v17.3.1 Platform Linux darkk-ya-laptop 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem dgram What steps will reproduce the bug? Use t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | darkk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width