Skip to content

fix(windows): replace native scanner with fs scan to fix Segfault (#592) - #620

Open
derekxia1988 wants to merge 1 commit into
ZToolsCenter:mainfrom
derekxia1988:fix/windows-scanner-segfault-592
Open

fix(windows): replace native scanner with fs scan to fix Segfault (#592)#620
derekxia1988 wants to merge 1 commit into
ZToolsCenter:mainfrom
derekxia1988:fix/windows-scanner-segfault-592

Conversation

@derekxia1988

Copy link
Copy Markdown

问题

关闭 #592

ztools_native.nodescanWindowsShortcuts 在以下条件下于 Electron 主进程中 Segfault:

  • Windows 桌面文件夹被重定向到含非 ASCII 字符的路径(如 OneDrive/桌面
  • uiohook-napi 全局键盘钩子已在 DoubleTapManager 中启动

Segfault 发生在 native 层,无法被 JS try/catch 捕获,导致进程直接退出(exit code 139)。

已确认:在纯 Node.js 环境中以相同参数调用不会崩溃;仅在 Electron 主进程中复现。

修复

windowsScanner.ts 中的 WindowsShortcutScanner.scan() 替换为 fs.readdirSync 递归扫描 .lnk 文件,不调用 native 模块,从根本上消除崩溃路径。

已知差异(相比原生实现)

功能 原生实现 本 PR
.lnk 快捷方式
.url 快捷方式 ❌ 不显示
desktop.ini 本地化名称 ❌ 显示文件名
.lnk 目标路径解析(用于去重) ❌ 降级为 .lnk 路径去重
含非 ASCII 桌面路径的 Windows 系统 ❌ 崩溃 ✅ 正常

复现环境

  • Windows 11 Pro 10.0.26200
  • 桌面重定向:C:\Users\YX\OneDrive\桌面
  • ZTools 3.0.1 / Electron 41.4.0

🤖 Generated with Claude Code

…oolsCenter#592)

ztools_native.node's scanWindowsShortcuts Segfaults in the Electron main
process on Windows systems where the desktop folder is redirected to a
path containing non-ASCII characters (e.g. OneDrive/桌面). The crash
bypasses try/catch and is suspected to be a conflict between uiohook-napi
and the native module's Win32 API calls.

Replace WindowsShortcutScanner.scan() with fs.readdirSync recursion over
.lnk files. No native module is called, so the crash cannot occur.

Known regressions vs. the native implementation:
- .url shortcuts in Start Menu are not shown
- desktop.ini localized names are not resolved (shows file basename)
- .lnk target paths are not resolved (deduplication falls back to .lnk path)

Fixes ZToolsCenter#592
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant