Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hang on startup: MinGW interop failure with MIEngine due to line ending issues #119

Open
malsyned opened this issue Aug 27, 2024 · 0 comments

Comments

@malsyned
Copy link

Windows 11
VSCode 1.92.2
mingw-w64-clang-x86_64-lldb-mi r93.a6c8c66-1

When trying to use the MSys2 build of lldb-mi, debug hangs indefinitely when I try to launch it. I get the following errors in the VSCode debug console with "logging": { "engineLogging": true, }:

[Error] 1: (716) MI parsing error: CString not terminated: ""C:\\Users\\VBoxUser\\Documents\\cortex-r-template"
[Error] 1: (716) MI parsing error: Result expected: "path="C:\\Users\\VBoxUser\\Documents\\cortex-r-template"
[Error] 1: (716) MI parsing error: trailing chars: ""C:\\Users\\VBoxUser\\Documents\\cortex-r-template"
# ...
1: (736) Send Event AD7MessageEvent
[Error] 1: (738) MI parsing error: CString not terminated: """

I collected a log file, lldb-mi-20240726131431.log. The main clue in it is that lines representing commands from MIEngine are CRLF-terminated, but lines generated by llvm-mi are only LF-terminated. The MIEngine error happens after this exchange:

F,26/08/24 13:14:31,1003-environment-cd C:\\Users\\VBoxUser\\Documents\\cortex-r-template<CR><LF>
F,26/08/24 13:14:31,1003^done,path="C:\\Users\\VBoxUser\\Documents\\cortex-r-template<CR>"<LF>

What this looks like to me is that llvm-mi is reading the environment-cd command and treating the trailing <CR> as part of the command, not part of the line break. Then it echoes that wrong path back in the done,path= response, and MIEngine interprets that as an end-of-line and complains about "CString not terminated". You can even see it try to parse the closing quote as a separate command at the end after it's done reporting the first error:

[Error] 1: (738) MI parsing error: CString not terminated: """

My guess here is that whatever workarounds the MSys2 runtime has for line ending differences between POSIX and Windows, it's not working correctly (or making things worse) between MIEngine and lldb-mi. I couldn't find much about how the MSys2 runtime handles newlines, except this bit saying that it does something:

msys-2.0.dll includes the following changes to support using native Windows programs
...
Conversion of output of native Windown applications from Windows line endings to POSIX line endings by removing trailing '\r' characters
(https://www.msys2.org/wiki/How-does-MSYS2-differ-from-Cygwin/)

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

No branches or pull requests

3 participants
@malsyned and others