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

"unknown error" when running Rust project on Windows #632

Closed
Sheepyhead opened this issue Feb 3, 2022 · 9 comments
Closed

"unknown error" when running Rust project on Windows #632

Sheepyhead opened this issue Feb 3, 2022 · 9 comments
Labels
cause:Not a bug Everything works as intended, not a bug.

Comments

@Sheepyhead
Copy link

OS: Windows 10 21H1
VSCode version: 1.63.2
CodeLLDB version: 1.6.10
Compiler: rustc 1.60.0-nightly (5e57faa78 2022-01-19)
Debuggee: x86_64-windows-msvc

I have a game written in the Rust-based game engine Bevy that has been untouched for about half a year, and when I went back to it, upgrading stuff along the way, all of a sudden it would no longer run through the vscode-lldb extension. Compilation succeeds, and using cargo run on its own works just fine, but vscode-lldb fails with an unknown error in debug_session.rs, and I can't immediately tell where that error could come from in that specific file.

Verbose log

Listening on port 64788
[2022-02-02T18:05:46.350Z DEBUG codelldb] New debug session
INFO(Python) 19:05:46 formatters: Initializing
INFO(Python) 19:05:46 formatters.rust: Initializing
[2022-02-02T18:05:46.718Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true},"type":"request","seq":1}
[2022-02-02T18:05:46.718Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"rust_panic","label":"Rust: on panic"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2022-02-02T18:05:46.724Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Debug executable 'rusten_djaevel'","args":[],"cwd":"C:\Users\Sheepyhead\repo\rusten_djaevel","env":{"CARGO_MANIFEST_DIR":"C:\Users\Sheepyhead\repo\rusten_djaevel","RUST_BACKTRACE":"full"},"__configurationTarget":5,"relativePathBase":"c:\Users\Sheepyhead\repo\rusten_djaevel","program":"c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe","sourceLanguages":["rust"],"_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null,"evaluateForHovers":true,"commandCompletions":true,"reproducer":false},"__sessionId":"02b726d4-84e4-48e4-99ee-20b9d4bfdc84"},"type":"request","seq":2}
[2022-02-02T18:05:46.724Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"capabilities","body":{"capabilities":{"exceptionBreakpointFilters":[{"default":true,"filter":"rust_panic","label":"Rust: on panic"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}}
[2022-02-02T18:05:47.019Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"initialized"}
[2022-02-02T18:05:47.019Z DEBUG codelldb::debug_session] Debug event: 000001C5FEBFDFE0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {rusten_djaevel.exe}
[2022-02-02T18:05:47.020Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"module","body":{"module":{"addressRange":"FFFFFFFFFFFFFFFF","id":"FFFFFFFFFFFFFFFF","name":"rusten_djaevel.exe","path":"c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe","symbolFilePath":"c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.020Z DEBUG codelldb::dap_codec] <-- {"type":"request","seq":4,"command":"runInTerminal","arguments":{"args":["c:\Users\Sheepyhead\.vscode\extensions\vadimcn.vscode-lldb-1.6.10\adapter\codelldb.exe","terminal-agent","--port=64791"],"cwd":"","kind":"integrated","title":"Debug executable 'rusten_djaevel'"}}
[2022-02-02T18:05:47.023Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":3}
[2022-02-02T18:05:47.023Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2022-02-02T18:05:47.033Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2022-02-02T18:05:47.033Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2022-02-02T18:05:47.039Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":[]},"type":"request","seq":5}
[2022-02-02T18:05:47.039Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setExceptionBreakpoints"}
[2022-02-02T18:05:47.042Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":6}
[2022-02-02T18:05:47.042Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"configurationDone"}
[2022-02-02T18:05:47.045Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":7}
[2022-02-02T18:05:47.045Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"threads","body":{"threads":[]}}
[2022-02-02T18:05:47.048Z DEBUG codelldb::dap_codec] --> {"type":"response","seq":8,"command":"runInTerminal","request_seq":4,"success":true,"body":{"shellProcessId":43900}}
[adapter\src\terminal.rs:104] FreeConsole() = 1
[2022-02-02T18:05:47.103Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"output":"Launching: c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe\n"}}
[adapter\src\terminal.rs:105] AttachConsole(pid) = 1
[adapter\src\terminal.rs:109] FreeConsole() = 1
[2022-02-02T18:05:47.298Z ERROR codelldb::debug_session] unknown error
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":false,"command":"","message":"unknown error","show_user":true}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802B9430 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {rusten_djaevel.exe}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA0F0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {ntdll.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA170 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {ntdll.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":6,"event":"module","body":{"module":{"addressRange":"FFFFFFFFFFFFFFFF","id":"FFFFFFFFFFFFFFFF","name":"rusten_djaevel.exe","path":"c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe","symbolFilePath":"c:\Users\Sheepyhead\repo\rusten_djaevel\target\debug\rusten_djaevel.exe","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA2B0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {kernel32.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":7,"event":"module","body":{"module":{"addressRange":"7FFBA1A50000","id":"7FFBA1A50000","name":"ntdll.dll","path":"C:\Windows\System32\ntdll.dll","symbolFilePath":"C:\Windows\System32\ntdll.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA8F0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {kernel32.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":8,"event":"module","body":{"module":{"addressRange":"7FFBA1A50000","id":"7FFBA1A50000","name":"ntdll.dll","path":"C:\Windows\System32\ntdll.dll","symbolFilePath":"C:\Windows\System32\ntdll.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA6F0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {KernelBase.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA4B0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {KernelBase.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":9,"event":"module","body":{"module":{"addressRange":"7FFBA1480000","id":"7FFBA1480000","name":"kernel32.dll","path":"C:\Windows\System32\kernel32.dll","symbolFilePath":"C:\Windows\System32\kernel32.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BA8B0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {ucrtbase.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BBCB0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {ucrtbase.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":10,"event":"module","body":{"module":{"addressRange":"7FFBA1480000","id":"7FFBA1480000","name":"kernel32.dll","path":"C:\Windows\System32\kernel32.dll","symbolFilePath":"C:\Windows\System32\kernel32.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BBD70 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {vcruntime140.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":11,"event":"module","body":{"module":{"addressRange":"7FFB9F160000","id":"7FFB9F160000","name":"KernelBase.dll","path":"C:\Windows\System32\KernelBase.dll","symbolFilePath":"C:\Windows\System32\KernelBase.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802BB230 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000002 (modules-loaded), data = {vcruntime140.dll}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":12,"event":"module","body":{"module":{"addressRange":"7FFB9F160000","id":"7FFB9F160000","name":"KernelBase.dll","path":"C:\Windows\System32\KernelBase.dll","symbolFilePath":"C:\Windows\System32\KernelBase.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::debug_session] Debug event: 000001C5802B9BB0 Event: broadcaster = 000001C580A34DA8 (lldb.target), type = 0x00000004 (modules-unloaded), data = {rusten_djaevel.exe}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":13,"event":"module","body":{"module":{"addressRange":"7FFB9F480000","id":"7FFB9F480000","name":"ucrtbase.dll","path":"C:\Windows\System32\ucrtbase.dll","symbolFilePath":"C:\Windows\System32\ucrtbase.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":14,"event":"module","body":{"module":{"addressRange":"7FFB9F480000","id":"7FFB9F480000","name":"ucrtbase.dll","path":"C:\Windows\System32\ucrtbase.dll","symbolFilePath":"C:\Windows\System32\ucrtbase.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":15,"event":"module","body":{"module":{"addressRange":"7FFB86BD0000","id":"7FFB86BD0000","name":"vcruntime140.dll","path":"C:\Windows\System32\vcruntime140.dll","symbolFilePath":"C:\Windows\System32\vcruntime140.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":16,"event":"module","body":{"module":{"addressRange":"7FFB86BD0000","id":"7FFB86BD0000","name":"vcruntime140.dll","path":"C:\Windows\System32\vcruntime140.dll","symbolFilePath":"C:\Windows\System32\vcruntime140.dll","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2022-02-02T18:05:47.298Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":17,"event":"module","body":{"module":{"id":"FFFFFFFFFFFFFFFF","name":""},"reason":"removed"}}
[2022-02-02T18:05:47.316Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
[2022-02-02T18:05:47.317Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"disconnect"}
[2022-02-02T18:05:47.804Z DEBUG codelldb::dap_session] Client has disconnected
[2022-02-02T18:05:47.804Z DEBUG codelldb::debug_session] End of the requests stream
[2022-02-02T18:05:47.804Z DEBUG codelldb::debug_session] DebugSession::drop()
[2022-02-02T18:05:47.804Z DEBUG codelldb] Session has ended
[2022-02-02T18:05:47.815Z DEBUG codelldb] Exiting

@vadimcn
Copy link
Owner

vadimcn commented Feb 5, 2022

The error is coming from LLDB's "launch process" API, there is no further information here. Could be a missing DLL or something like that.

@Sheepyhead
Copy link
Author

Is there any way to get any further information? I can use this in other projects on the same machine, and this project runs normally if I just run cargo run in terminal

@vadimcn
Copy link
Owner

vadimcn commented Feb 5, 2022

Try Process Monitor.

@Sheepyhead
Copy link
Author

Okay I'm looking at a capture of when it happens with Process Monitor but to be honest there's a lot of information here and I'm not sure what I'm even looking for. I'm not seeing any obvious signs of an error occurring even. The executable for my project seems to exit with an exit status "-1073741515" or 0xC0000135 which seems to be STATUS_DLL_NOT_FOUND so there's a missing DLL somewhere? The last dll it loads before this occurs is vcruntime140.dll, which I think is loaded successfully? It's odd because I don't have this issue in any other project on this machine, and like I said I can run it normally just fine, it's only when running through vscode-lldb it's an issue

@vadimcn
Copy link
Owner

vadimcn commented Mar 6, 2022

Yes, looks like a missing DLL. IIRC, you should see Windows searching for a DLL file before it fails with this error, though.

More tools to try:
https://docs.microsoft.com/en-us/cpp/build/reference/dependents?view=msvc-170.
https://github.com/lucasg/Dependencies

@vadimcn vadimcn added the cause:Not a bug Everything works as intended, not a bug. label Mar 13, 2022
@vadimcn vadimcn closed this as completed Mar 13, 2022
@agg23
Copy link

agg23 commented Apr 2, 2022

For posterity, Bevy recommends enabling dynamic linking, which VSCode doesn't nicely handle (see bevyengine/bevy#2589). In general, you need to update PATH to include the dylibs.

For Bevy in particular, you can add the following envvars to your launch.json config:

"env": {
        "CARGO_MANIFEST_DIR": "${workspaceFolder}",
        "PATH": "${env:USERPROFILE}/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/bin;${workspaceFolder}/target/debug/deps;${env:PATH}",
      },

@Sheepyhead
Copy link
Author

I can confirm that this works! I forgot that I'd enabled dynamic linking since I normally don't do that, thanks for the workaround!

@hintron
Copy link

hintron commented Aug 15, 2022

This fixed the issue for me (I'm debugging a Bevy game with dynamic linking enabled, too). Thanks a ton, @agg23!

@Technostalgic
Copy link

For posterity, Bevy recommends enabling dynamic linking, which VSCode doesn't nicely handle (see bevyengine/bevy#2589). In general, you need to update PATH to include the dylibs.

For Bevy in particular, you can add the following envvars to your launch.json config:

"env": {
        "CARGO_MANIFEST_DIR": "${workspaceFolder}",
        "PATH": "${env:USERPROFILE}/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/bin;${workspaceFolder}/target/debug/deps;${env:PATH}",
      },

Can confirm this works for me also. Note that you may need to change part of the PATH value. I, for one am using the stable build, not nightly, so I had to change nightly-x86_64-pc-windows-msvc to stable-x86_64-pc-windows-msvc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cause:Not a bug Everything works as intended, not a bug.
Projects
None yet
Development

No branches or pull requests

5 participants