[BUG]遇到个bug,它自己改了,有效果并生成了一个报告 #644
SuiYuanMingMing
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
[BUG] Adding a workspace whose path contains a U+XX00 char (e.g. 开 U+5F00) fails: Win32 picker truncates the UTF-16 path at a single 0x00 byte
Summary
On Windows, "Add workspace" opens the native
IFileOpenDialog(spawned child process + koffi COM).The selected folder path is read back as a UTF-16LE
LPWSTR.readUtf16()inpackages/host/directory-picker-native/src/win32-dialog-bindings.tstreats any single 0x00 byte at aneven offset as the string terminator, but a UTF-16 terminator is a full
0x0000code unit (two zerobytes). Any path containing a CJK character whose low byte is 0x00 (e.g. 开 = U+5F00, 一 = U+4E00) at an
even code-unit position is silently truncated at that character. The GUI then calls
workspace.createwith the truncated path, the server's
fs.realpaththrowsENOENT, and the user sees:Environment
native)@deepseek-ai/dsh-host-directory-picker-native0.1.0-rc.6 (installed), also current onmaster(checked 2026-08-14)Repro
For example, under a Chinese-named parent:
<ProjectRoot>\01开发域(the offending character 开 = U+5F00, low byte 0x00, sits at an even code-unit offset after
01).path into the dialog produces the same result.)
workspace create failed: workspace-invalid-path: ... realpath '<ProjectRoot>\01'— the
开发域suffix vanished because the path was cut right before 开.Note the Chinese-named parent segment survives because none of its code units has a 0x00 low byte
(which is a fingerprint of this exact bug, not a sign that CJK paths "mostly work").
Root cause
packages/host/directory-picker-native/src/win32-dialog-bindings.ts:开= U+5F00 encodes little-endian as00 5F, so the loop stops right at the first byte of 开.Reproduction of the loop semantics on the path (Node):
Secondary issue (same function, lower severity):
koffi.view(address, 32768)reads up to 32 KiB past theCoTaskMemAlloc'd string — a latent out-of-bounds read hazard that should be bounded differently.
Suggested fix (one line)
A terminator is only a complete
0x0000code unit. Optionally also guard the read window with a muchsmaller bounded scan and/or use the buffer size the string actually owns.
Server side is not at fault
Verified by calling
POST /api/workspace.createwith the full path directly — the server registers theworkspace correctly.
fs.realpath, the RPC transport, and the payload schema all handle Unicode pathsfine. The truncation happens purely in the client-side native picker's
readUtf16.All reactions