René's URL Explorer Experiment


Title: buffer: UTF-16LE indexOf can hang on unaligned Buffer views · Issue #65959 · nodejs/node · GitHub

Open Graph Title: buffer: UTF-16LE indexOf can hang on unaligned Buffer views · Issue #65959 · nodejs/node

X Title: buffer: UTF-16LE indexOf can hang on unaligned Buffer views · Issue #65959 · nodejs/node

Description: Version v27.0.0-pre (b805fb5158a) Platform Darwin 24.6.0 arm64 Subsystem buffer What steps will reproduce the bug? Buffer#indexOf() can hang when its receiver is an unaligned view. The child process timeout prevents the reproduction from...

Open Graph Description: Version v27.0.0-pre (b805fb5158a) Platform Darwin 24.6.0 arm64 Subsystem buffer What steps will reproduce the bug? Buffer#indexOf() can hang when its receiver is an unaligned view. The child proces...

X Description: Version v27.0.0-pre (b805fb5158a) Platform Darwin 24.6.0 arm64 Subsystem buffer What steps will reproduce the bug? Buffer#indexOf() can hang when its receiver is an unaligned view. The child proces...

Opengraph URL: https://github.com/nodejs/node/issues/65959

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"buffer: UTF-16LE indexOf can hang on unaligned Buffer views","articleBody":"### Version\n\nv27.0.0-pre (`b805fb5158a`)\n\n### Platform\n\n```text\nDarwin 24.6.0 arm64\n```\n\n### Subsystem\n\nbuffer\n\n### What steps will reproduce the bug?\n\n`Buffer#indexOf()` can hang when its receiver is an unaligned view. The child process timeout prevents the reproduction from hanging indefinitely.\n\n```js\n'use strict';\n\nconst { spawnSync } = require('node:child_process');\n\nfor (const prefixLength of [0, 1]) {\n  const source = `\n    const data = Buffer.from('abc', 'utf16le');\n    const backing = Buffer.alloc(data.length + ${prefixLength});\n    data.copy(backing, ${prefixLength});\n\n    const view = backing.subarray(${prefixLength});\n    console.log(view.indexOf('a', 0, 'utf16le'));\n  `;\n\n  const result = spawnSync(process.execPath, ['-e', source], {\n    encoding: 'utf8',\n    timeout: 2000,\n  });\n\n  console.log({\n    prefixLength,\n    status: result.status,\n    error: result.error?.code,\n    stdout: result.stdout.trim(),\n  });\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nIt's consistent when the receiver view starts at an odd byte offset. The aligned control returns normally.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nBoth searches should terminate and return `0`.\nThe views contain the same bytes, and the UTF-16LE value begins at index 0 of each view. The result should not depend on the underlying memory address.\n\n### What do you see instead?\n\nThe aligned view returns `0`. The view starting at byte offset 1 does not complete before the timeout:\n\n```\n{ prefixLength: 0, status: 0, error: undefined, stdout: '0' }\n{ prefixLength: 1, status: null, error: 'ETIMEDOUT', stdout: '' }\n```\n\n### Additional information\n\n`Buffer#indexOf()` [passes the receiver data to the 16-bit search](https://github.com/nodejs/node/blob/b805fb5158a33f6dc0c213165edddc35045f4eb3/src/node_buffer.cc#L1119-L1124), while `nbytes` [aligns matched addresses down](https://github.com/nodejs/node/blob/b805fb5158a33f6dc0c213165edddc35045f4eb3/deps/nbytes/include/nbytes.h#L459-L465). For an odd-offset view, this can move before the start of the view and appears to cause the hang.\n\nThis is distinct from #26448, which concerns search-offset rounding, and remains reproducible after #65905, which affects UTF-16LE decoding rather than `Buffer#indexOf()`.\n\nCopying the view or using a `Buffer` needle avoids the hang. Both workarounds return `0` locally:\n```js\nBuffer.from(view).indexOf('a', 0, 'utf16le');\nview.indexOf(Buffer.from('a', 'utf16le'));\n```","author":{"url":"https://github.com/inoway46","@type":"Person","name":"inoway46"},"datePublished":"2026-09-10T11:52:06Z","url":"https://github.com/nodejs/node/issues/65959"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dd47e6fb-4e64-a679-fc79-e0d20efb2a08
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDC0A:257A3D:7948E1:A1751D:6AED2628
html-safe-nonceca939e40e33c7160c0232b668da6cd681420405603661c11a46752c890c2725d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzBBOjI1N0EzRDo3OTQ4RTE6QTE3NTFEOjZBRUQyNjI4IiwidmlzaXRvcl9pZCI6IjcxNjgyNzk4NjczOTk0MTUzMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac20b7a13b157efb9830751104bc3ee31bb4d4a7e29c27a747f9298498f1fdd187
hovercard-subject-tagissue:5411811927
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65959/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ee09a9926669128d8c2af20028cf805a965f2d19c587d9cf86e0d549b83daeba/nodejs/node/issues/65959
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ee09a9926669128d8c2af20028cf805a965f2d19c587d9cf86e0d549b83daeba/nodejs/node/issues/65959
og:image:altVersion v27.0.0-pre (b805fb5158a) Platform Darwin 24.6.0 arm64 Subsystem buffer What steps will reproduce the bug? Buffer#indexOf() can hang when its receiver is an unaligned view. The child proces...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameinoway46
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/65959#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F65959
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F65959
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/65959
Reloadhttps://github.com/nodejs/node/issues/65959
Reloadhttps://github.com/nodejs/node/issues/65959
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues657 (657)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65959
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65959
#65968https://github.com/nodejs/node/pull/65968
buffer: UTF-16LE indexOf can hang on unaligned Buffer viewshttps://github.com/nodejs/node/issues/65959#top
#65968https://github.com/nodejs/node/pull/65968
https://github.com/inoway46
inoway46https://github.com/inoway46
on Sep 10, 2026https://github.com/nodejs/node/issues/65959#issue-5411811927
passes the receiver data to the 16-bit searchhttps://github.com/nodejs/node/blob/b805fb5158a33f6dc0c213165edddc35045f4eb3/src/node_buffer.cc#L1119-L1124
aligns matched addresses downhttps://github.com/nodejs/node/blob/b805fb5158a33f6dc0c213165edddc35045f4eb3/deps/nbytes/include/nbytes.h#L459-L465
#26448https://github.com/nodejs/node/issues/26448
#65905https://github.com/nodejs/node/pull/65905
https://github.com/bitpshr
bitpshrhttps://github.com/bitpshr
on Sep 10, 2026https://github.com/nodejs/node/issues/65959#issuecomment-5625728089
#65968https://github.com/nodejs/node/pull/65968
#65960https://github.com/nodejs/node/pull/65960
bitpshrhttps://github.com/bitpshr
on Sep 19, 2026https://github.com/nodejs/node/issues/65959#event-31461780891
deps: read unaligned two byte data in nbytes searchhttps://github.com/bitpshr/node/commit/f3607899e081bff3049c59002532d735ebd8d6b6
f360789https://github.com/bitpshr/node/commit/f3607899e081bff3049c59002532d735ebd8d6b6
bitpshrhttps://github.com/bitpshr
on Oct 6, 2026https://github.com/nodejs/node/issues/65959#event-32563881114
deps: fix nbytes two byte search on unaligned datahttps://github.com/bitpshr/node/commit/72df60f8aa21bbb30a6b3622aaacdf9e0be803f6
72df60fhttps://github.com/bitpshr/node/commit/72df60f8aa21bbb30a6b3622aaacdf9e0be803f6
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/65959
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65959
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.