fix: avoid panic on multi-byte UTF-8 chars in hash placeholder iterator#8790
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@rolldown/browser
@rolldown/debug
@rolldown/pluginutils
rolldown
@rolldown/binding-android-arm64
@rolldown/binding-darwin-arm64
@rolldown/binding-darwin-x64
@rolldown/binding-freebsd-x64
@rolldown/binding-linux-arm-gnueabihf
@rolldown/binding-linux-arm64-gnu
@rolldown/binding-linux-arm64-musl
@rolldown/binding-linux-ppc64-gnu
@rolldown/binding-linux-s390x-gnu
@rolldown/binding-linux-x64-gnu
@rolldown/binding-linux-x64-musl
@rolldown/binding-openharmony-arm64
@rolldown/binding-wasm32-wasi
@rolldown/binding-win32-arm64-msvc
@rolldown/binding-win32-x64-msvc
commit: |
Contributor
Benchmarks Rust |
hyf0
approved these changes
Mar 19, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
59208fe to
177a092
Compare
Member
Merge activity
|
…or (#8790) From #8783 to trigger preview When source files contain multi-byte UTF-8 characters (e.g. Chinese filenames in SVG imports), the hash placeholder iterator could panic because the computed `search_end` byte offset landed in the middle of a multi-byte character, making `&str[left_pos..search_end]` an invalid slice. ## Changes - **`crates/rolldown_utils/src/hash_placeholder.rs`** — Replace `str::find` over `self.s[left_pos..search_end]` with `memchr::memmem::find` over `self.s.as_bytes()[left_pos..search_end]`. Since all placeholder delimiters (`!~{`, `}~`) are ASCII, byte-level search is correct and the resulting `right_pos` is always a valid char boundary. - Add regression tests covering placeholders adjacent to Chinese characters and cases where the 3-byte boundary of a CJK character straddles `search_end`. ``` thread panicked at crates/rolldown_utils/src/hash_placeholder.rs:56:38: byte index 1045 is not a char boundary; it is inside '级' (bytes 1044..1047) of `...vue.runtime.esm-bundler-!~{001}~.js`... ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Panic]: A panic occurred during the build process</issue_title> > <issue_description>### Panic message > > ```Shell > rendering chunks (411)...Rolldown panicked. This is a bug in Rolldown, not your code. > > thread '<unnamed>' (39028) panicked at crates\rolldown_utils\src\hash_placeholder.rs:56:38: > byte index 1045 is not a char boundary; it is inside '级' (bytes 1044..1047) of `import{C as e,D as t,Dt as n,E as r,J as i,K as a,O as o,S as s,Ut as ee,X as c,Z as l,b as u,ct as d,m as f,st as p,vt as m,x as h}from"./vue.runtime.esm-bundler-!~{001}~.js";import{t as g}from"./objectSpread2-!~{003}~.js";import{s as _}from"./router-!~{0`[...] > Rolldown panicked. This is a bug in Rolldown, not your code. > Rolldown panicked. This is a bug in Rolldown, not your code. > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace > Rolldown panicked. This is a bug in Rolldown, not your code. > Rolldown panicked. This is a bug in Rolldown, not your code. > > thread '<unnamed>' (45852) panicked at crates\rolldown_utils\src\hash_placeholder.rs:56:38: > byte index 582 is not a char boundary; it is inside '级' (bytes 581..584) of `import{C as e,D as t,Dt as n,J as r,K as i,O as a,Q as o,S as s,T as c,U as l,Ut as u,W as d,b as f,ct as p,m,n as h,st as g,u as _,vt as v,x as y}from"./vue.runtime.esm-bundler-!~{001}~.js";import{a as b}from"./dist-!~{005}~.js";import"./router-!~{00d}~.j`[...] > Rolldown panicked. This is a bug in Rolldown, not your code. > ``` > > ### Reproduction > > It seems the issue was related to Chinese characters in my SVG file name. After I renamed the Chinese names to English, the problem was fixed. > > ### System Info > > ```Shell > System: > OS: Windows 11 10.0.26200 > CPU: (22) x64 Intel(R) Core(TM) Ultra 9 185H > Memory: 6.36 GB / 31.43 GB > Binaries: > Node: 22.14.0 - C:\Program Files\nodejs\node.EXE > Yarn: 1.22.22 - C:\Users\jay\AppData\Roaming\npm\yarn.CMD > npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD > pnpm: 10.30.2 - C:\Users\jay\AppData\Roaming\npm\pnpm.CMD > Browsers: > Chrome: 146.0.7680.154 > Edge: Chromium (140.0.3485.54) > Firefox: 141.0.3 - C:\Program Files\Mozilla Firefox\firefox.exe > Internet Explorer: 11.0.26100.7309 > ``` > > ### Additional context > > _No response_</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #8782 - Fixes #8795 - Fixes #8806 - Fixes #8808 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Send tasks to Copilot coding agent from [Slack](https://gh.io/cca-slack-docs) and [Teams](https://gh.io/cca-teams-docs) to turn conversations into code. Copilot posts an update in your thread when it's finished.
177a092 to
fd0adb5
Compare
1 task
This was referenced Mar 23, 2026
Closed
Merged
shulaoda
added a commit
that referenced
this pull request
Mar 23, 2026
## [1.0.0-rc.11] - 2026-03-23 ### 🚀 Features - magicString replace with regex (#8802) by @IWANABETHATGUY - support `output.sourcemapExcludeSources` option (#8828) by @sapphi-red - support `getIndentString` in MagicString (#8775) by @IWANABETHATGUY - MagicString ignoreList support (#8773) by @IWANABETHATGUY ### 🐛 Bug Fixes - types: remove `pluginName` from `MinimalPluginContext` (#8864) by @sapphi-red - do not report eval?.() as direct eval (#8860) by @IWANABETHATGUY - handle negative indices, overlapping ranges, and moved content in MagicString remove (#8829) by @IWANABETHATGUY - enable arbitrary_precision for serde_json to fix JSON float parsing (#8848) by @elderapo - resolve TypeScript lint errors (#8841) by @Boshen - avoid panic on multi-byte UTF-8 chars in hash placeholder iterator (#8790) by @shulaoda - ci: skip failing vite build watch raw query test (#8840) by @Boshen - ci: use step-level env override to unset VITE_PLUS_CLI_BIN in vite tests (#8838) by @Boshen - ci: move vite tests into CI workflow by @Boshen - ci: unset all VITE_PLUS_* env vars in vite-tests workflow (#8837) by @Boshen - test: skip watch CLI tests on Windows (#8830) by @Boshen - ci: unset VITE_PLUS_CLI_BIN in vite-tests workflow (#8832) by @Boshen - remove redundant bare side-effect imports in entry/facade chunks (#8804) by @h-a-n-a - magicString prepend issues (#8797) by @IWANABETHATGUY - ci: use `vpx` instead of `vp exec` for `pkg-pr-new` (#8827) by @Boshen - set `order` for callable plugins (#8815) by @sapphi-red - handle reversed slice ranges with moved content (#8750) by @IWANABETHATGUY - update emnapi to latest to avoid version mismatch (#8781) by @sapphi-red - external.md on Windows OS (#8780) by @bddjr - align MagicString length/isEmpty with reference magic-string (#8776) by @IWANABETHATGUY ### 🚜 Refactor - extract canonical_ref_resolving_namespace helper (#8836) by @Boshen ### 📚 Documentation - improve external examples for cross-platform correctness (#8786) by @hyf0-agent - update reference to transform function in plugin API documentation (#8778) by @zOadT ### ⚡ Performance - reduce timing of `dervie_entries_aware_chunk_name` (#8847) by @AliceLanniste - bench: remove redundant sourcemap benchmark cases (#8825) by @Boshen - reduce intermediate allocations in `collapse_sourcemaps` (#8821) by @Boshen - enable parallel AST cloning on macOS (#8814) by @Boshen ### 🧪 Testing - watch: use polling watcher and retry for watch error test (#8772) by @sapphi-red ### ⚙️ Miscellaneous Tasks - justfile: skip setup-vite-plus if vp is already installed (#8862) by @Boshen - add expectWarning option to test config (#8861) by @IWANABETHATGUY - justfile: support windows for `just setup` (#8846) by @AliceLanniste - deps: update rust crates (#8852) by @renovate[bot] - deps: update endbug/version-check action to v3 (#8855) by @renovate[bot] - deps: update github-actions (#8853) by @renovate[bot] - deps: update dependency vitepress to v2.0.0-alpha.17 (#8854) by @renovate[bot] - deps: update npm packages (#8851) by @renovate[bot] - bench: use mimalloc as global allocator in bench crate (#8844) by @IWANABETHATGUY - reuse native build artifact in node-validation job (#8826) by @Boshen - speed up CodSpeed benchmark build by disabling LTO (#8824) by @Boshen - remove redundant critcmp benchmark job (#8823) by @Boshen - deps: update rust crate oxc_sourcemap to v6.1.0 (#8785) by @renovate[bot] - node: migrate oxlint and oxfmt to Vite+ (#8813) by @Boshen - revert namespace runners for release build jobs (#8820) by @Boshen - migrate runners to namespace (#8819) by @Boshen - test: relax test utils path assertion to support git worktrees (#8816) by @younggglcy - rename `examples/lazy` to `examples/lazy-compilation` (#8789) by @shulaoda - improve "needs reproduction" wording by @Boshen - deps: update dependency oxlint-tsgolint to v0.17.1 (#8807) by @renovate[bot] - enable 7 previously-skipped MagicString tests (#8771) by @IWANABETHATGUY - upgrade oxc to 0.121.0 (#8784) by @shulaoda - increase Windows dev drive size from 12GB to 20GB (#8779) by @Copilot ### ❤️ New Contributors * @elderapo made their first contribution in [#8848](#8848) * @younggglcy made their first contribution in [#8816](#8816) * @bddjr made their first contribution in [#8780](#8780) * @zOadT made their first contribution in [#8778](#8778) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
This was referenced Mar 23, 2026
Closed
Merged
shulaoda
added a commit
that referenced
this pull request
Mar 23, 2026
## [1.0.0-rc.11] - 2026-03-23 ### 🚀 Features - magicString replace with regex (#8802) by @IWANABETHATGUY - support `output.sourcemapExcludeSources` option (#8828) by @sapphi-red - support `getIndentString` in MagicString (#8775) by @IWANABETHATGUY - MagicString ignoreList support (#8773) by @IWANABETHATGUY ### 🐛 Bug Fixes - forward test filters through vp run (#8870) by @younggglcy - types: remove `pluginName` from `MinimalPluginContext` (#8864) by @sapphi-red - do not report eval?.() as direct eval (#8860) by @IWANABETHATGUY - handle negative indices, overlapping ranges, and moved content in MagicString remove (#8829) by @IWANABETHATGUY - enable arbitrary_precision for serde_json to fix JSON float parsing (#8848) by @elderapo - resolve TypeScript lint errors (#8841) by @Boshen - avoid panic on multi-byte UTF-8 chars in hash placeholder iterator (#8790) by @shulaoda - ci: skip failing vite build watch raw query test (#8840) by @Boshen - ci: use step-level env override to unset VITE_PLUS_CLI_BIN in vite tests (#8838) by @Boshen - ci: move vite tests into CI workflow by @Boshen - ci: unset all VITE_PLUS_* env vars in vite-tests workflow (#8837) by @Boshen - test: skip watch CLI tests on Windows (#8830) by @Boshen - ci: unset VITE_PLUS_CLI_BIN in vite-tests workflow (#8832) by @Boshen - remove redundant bare side-effect imports in entry/facade chunks (#8804) by @h-a-n-a - magicString prepend issues (#8797) by @IWANABETHATGUY - ci: use `vpx` instead of `vp exec` for `pkg-pr-new` (#8827) by @Boshen - set `order` for callable plugins (#8815) by @sapphi-red - handle reversed slice ranges with moved content (#8750) by @IWANABETHATGUY - update emnapi to latest to avoid version mismatch (#8781) by @sapphi-red - external.md on Windows OS (#8780) by @bddjr - align MagicString length/isEmpty with reference magic-string (#8776) by @IWANABETHATGUY ### 🚜 Refactor - extract canonical_ref_resolving_namespace helper (#8836) by @Boshen ### 📚 Documentation - improve external examples for cross-platform correctness (#8786) by @hyf0-agent - update reference to transform function in plugin API documentation (#8778) by @zOadT ### ⚡ Performance - reduce timing of `dervie_entries_aware_chunk_name` (#8847) by @AliceLanniste - bench: remove redundant sourcemap benchmark cases (#8825) by @Boshen - reduce intermediate allocations in `collapse_sourcemaps` (#8821) by @Boshen - enable parallel AST cloning on macOS (#8814) by @Boshen ### 🧪 Testing - watch: use polling watcher and retry for watch error test (#8772) by @sapphi-red ### ⚙️ Miscellaneous Tasks - deps: update dependency @oxc-project/types to v0.122.0 (#8873) by @renovate[bot] - publish-to-npm: use correct vp pm publish (#8871) by @shulaoda - justfile: skip setup-vite-plus if vp is already installed (#8862) by @Boshen - add expectWarning option to test config (#8861) by @IWANABETHATGUY - justfile: support windows for `just setup` (#8846) by @AliceLanniste - deps: update rust crates (#8852) by @renovate[bot] - deps: update endbug/version-check action to v3 (#8855) by @renovate[bot] - deps: update github-actions (#8853) by @renovate[bot] - deps: update dependency vitepress to v2.0.0-alpha.17 (#8854) by @renovate[bot] - deps: update npm packages (#8851) by @renovate[bot] - bench: use mimalloc as global allocator in bench crate (#8844) by @IWANABETHATGUY - reuse native build artifact in node-validation job (#8826) by @Boshen - speed up CodSpeed benchmark build by disabling LTO (#8824) by @Boshen - remove redundant critcmp benchmark job (#8823) by @Boshen - deps: update rust crate oxc_sourcemap to v6.1.0 (#8785) by @renovate[bot] - node: migrate oxlint and oxfmt to Vite+ (#8813) by @Boshen - revert namespace runners for release build jobs (#8820) by @Boshen - migrate runners to namespace (#8819) by @Boshen - test: relax test utils path assertion to support git worktrees (#8816) by @younggglcy - rename `examples/lazy` to `examples/lazy-compilation` (#8789) by @shulaoda - improve "needs reproduction" wording by @Boshen - deps: update dependency oxlint-tsgolint to v0.17.1 (#8807) by @renovate[bot] - enable 7 previously-skipped MagicString tests (#8771) by @IWANABETHATGUY - upgrade oxc to 0.121.0 (#8784) by @shulaoda - increase Windows dev drive size from 12GB to 20GB (#8779) by @Copilot ### ❤️ New Contributors * @younggglcy made their first contribution in [#8870](#8870) * @elderapo made their first contribution in [#8848](#8848) * @bddjr made their first contribution in [#8780](#8780) * @zOadT made their first contribution in [#8778](#8778) --------- Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From #8783 to trigger preview
When source files contain multi-byte UTF-8 characters (e.g. Chinese filenames in SVG imports), the hash placeholder iterator could panic because the computed
search_endbyte offset landed in the middle of a multi-byte character, making&str[left_pos..search_end]an invalid slice.Changes
crates/rolldown_utils/src/hash_placeholder.rs— Replacestr::findoverself.s[left_pos..search_end]withmemchr::memmem::findoverself.s.as_bytes()[left_pos..search_end]. Since all placeholder delimiters (!~{,}~) are ASCII, byte-level search is correct and the resultingright_posis always a valid char boundary.search_end.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.