| Issue |
244032
|
| Summary |
[lldb] Crash (0xC0000005) in ClangExpressionDeclMap::FindExternalVisibleDecls when evaluating an unresolved name in a Rust frame on Windows (MSVC/PDB)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
ventsip
|
LLDB on Windows crashes with an access violation (`0xC0000005`) when an _expression_ names something it can't resolve while stopped in a Rust frame of an MSVC-targeted (PDB) binary. Literals and in-scope locals evaluate fine. Any unresolved name takes the whole process down, whether it's undefined or a local that isn't in scope yet. The expected result is an `error: use of undeclared identifier` diagnostic.
I reproduced it with the official LLVM 22.1.8 Windows release, with no Rust data formatters or scripts loaded.
### Reproducer
`src/main.rs` (a `cargo new` project, built with `cargo build`, debug profile, `x86_64-pc-windows-msvc`):
```rust
fn main() {
let owned = String::from("hi there");
let part: &str = &owned[0..2];
println!("{part}");
}
```
```
lldb.exe -b -o "b main.rs:3" -o "run" -o "_expression_ -- nosuchname" target\debug\<name>.exe
```
Results at the breakpoint on line 3:
| _expression_ | Result |
|---|---|
| `1+1` | `(int) $0 = 2` |
| `owned` | prints the value |
| `nosuchname` | crash, `Exception Code: 0xC0000005` |
| `part` (declared on line 3, so not yet in scope) | crash, `Exception Code: 0xC0000005` |
`SBFrame::EvaluateExpression` crashes the same way, with default options and with `SBExpressionOptions.SetLanguage()` set to C++, C99 or Unknown. Before the crash, `SBFrame::FindVariable`, `FindValue`, `GetValueForVariablePath` and `SBTarget::FindFunctions`/`FindGlobalVariables`/`FindTypes`/`FindSymbols` all return "not found" for the same name without crashing.
### _expression_ log
With `log enable lldb expr`, the log ends here:
```
Frame has language of type rust
Picked rust for _expression_ evaluation.
...
ClangExpressionDeclMap::FindExternalVisibleDecls for 'nosuchname' in a 'TranslationUnit'
CEDM::FEVD Searching the root namespace
```
So the crash seems to be in `ClangExpressionDeclMap::FindExternalVisibleDecls`, after the name misses the frame's locals and the search moves to the root namespace. I haven't identified the faulting line.
<details>
<summary>Crash output (unsymbolized, official 22.1.8 <code>liblldb.dll</code>, top frames)</summary>
```
Exception Code: 0xC0000005
liblldb.dll + 0x1B6615F
liblldb.dll + 0x1B65521
liblldb.dll + 0x1368754
liblldb.dll + 0x1364A7C
liblldb.dll + 0x136A7BB
liblldb.dll + 0x136A46A
liblldb.dll + 0x1334908
liblldb.dll + 0xE4E816
```
The diagnostics directory LLDB writes contains only `diagnostics.log` with: `This version of LLDB has no plugin for the language "rust". Inspection of frame variables will be limited.`
</details>
### Environment
- LLDB 22.1.8 (official `LLVM-22.1.8-win64.exe`, revision ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
- rustc 1.99.1 (58cf8f9c3 2026-10-13), `stable-x86_64-pc-windows-msvc`
- Windows 11 x64 (10.0.26300)
### Impact
IDE front ends that load `liblldb` in-process lose the whole debug session when this happens. For example, it surfaced in CodeLLDB (vadimcn/codelldb#1426) as an adapter crash when hovering a variable before its `let` had run. The hover there falls back to _expression_ evaluation.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs