fix(locale): strip POSIX encoding suffix from macOS locale vars to prevent ICU crash#1664
fix(locale): strip POSIX encoding suffix from macOS locale vars to prevent ICU crash#1664tpaustin wants to merge 1 commit intogeneralaction:mainfrom
Conversation
…event ICU crash On macOS 26+, ICU's uloc_getTableStringWithFallback crashes with a null pointer dereference when locale strings contain POSIX encoding suffixes (e.g. "en_US.UTF-8"). ICU expects bare locale identifiers like "en_US" and does not understand the ".UTF-8" encoding marker. The previous fix (PR generalaction#1640) changed the fallback from C.UTF-8 to en_US.UTF-8, but any .UTF-8 suffix triggers the same crash path in the newer macOS 26 ICU. macOS always uses UTF-8 regardless of locale, so the suffix carries no information and only breaks ICU lookup. Changes: - Strip POSIX encoding suffixes from all locale env vars after locale initialization on macOS (applied as a final pass in initializeShellEnvironment so it catches values from any source: existing env, shell detection, or fallback) - Change getFallbackUtf8Locale() on darwin to return "en_US" (no suffix) - Change LSEnvironment in package.json to use "en_US" / "en_US" so the Info.plist value is also ICU-safe before any JS runs - Update tests to reflect suffix-stripped expectations on macOS Closes generalaction#1633 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@tpaustin is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request updates macOS locale environment variable handling to strip POSIX encoding suffixes. Changes include modifying build configuration to use Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
.UTF-8) from locale env vars after initialization on macOS, catching values from any source (existing env, shell detection, or fallback)getFallbackUtf8Locale()on darwin to returnen_USinstead ofen_US.UTF-8LSEnvironmentinpackage.jsonto useen_USso theInfo.plistvalue is also ICU-safe before any JS runsBackground
Issue #1633 reports that Emdash crashes on launch on macOS 26+ starting from 0.4.44, and the crash persists through 0.4.45.
The crash stack is:
Root cause: ICU's
uloc_getTableStringWithFallbackon macOS 26+ crashes when it receives a locale string with a POSIX encoding suffix like.UTF-8. ICU expects bare locale identifiers (en_US, noten_US.UTF-8). On older macOS, Foundation silently stripped the encoding suffix before passing it to ICU; on macOS 26 this stripping no longer happens.PR #1632 changed the fallback from
C.UTF-8toen_US.UTF-8, and PR #1640 addedLSEnvironmentwithen_US.UTF-8— but any.UTF-8suffix triggers the same crash. macOS always uses UTF-8 regardless of locale, so the suffix is both redundant and harmful.Compatibility: The fix is fully backwards compatible. Stripping
.UTF-8fromen_US.UTF-8→en_USis semantically a no-op on macOS (all macOS locales are UTF-8). Older macOS versions tolerated the suffix; newer ones do not. The stripped value is what ICU always expected.Test plan
pnpm exec vitest run src/main/utils/__tests__/shellEnv.test.ts— all 15 tests passpnpm exec vitest run— all 863 tests passpnpm run buildpassespnpm run type-checkpassespnpm run dev— confirmed clean startup with no segfault)Closes #1633
🤖 Generated with Claude Code
Summary by CodeRabbit