Repository navigation
Description
Summary
On x86_64-pc-windows-msvc, a function that takes a struct larger than 16 bytes by value shows that parameter incorrectly in the debugger. Depending on the toolchain, either all its fields are unreadable (<Unable to read memory> / ???), or the parameter is missing from Locals entirely. Taking a reference to the parameter (let r = &res;) shows the correct values, so the data in memory is fine and only the parameter's location in the debug info seems wrong.
Bisected with cargo-bisect-rustc to #158734 ("Update to LLVM 23").
Minimal example
struct Term(u64);
struct Res {
term: Term,
ok: bool,
a: u64,
b: u64,
c: u64,
}
fn handle(res: Res) -> u64 {
if res.ok {
return res.term.0; // breakpoint here
}
0
}
fn main() {
println!(
"{}",
handle(Res { term: Term(1), ok: true, a: 1, b: 2, c: 3 })
);
}Default dev profile (opt-level = 0, debug = true).
Steps
cargo build- In VS Code, set a breakpoint on the
if res.okline and launchtarget\debug\<name>.exewith cpptools (cppvsdbg) or CodeLLDB, without rebuilding. - Look at
resin Locals.
Expected
res and its fields show their values (ok = true, a = 1, ...).
Actual
- Affected toolchains (1.99.0, 1.100.0, beta):
resis listed, but its fields show<Unable to read memory>/???, even plainu64fields. - Current nightly:
resis not listed in Locals at all. - The same applies to a method (
fn handle(&self, res: Res)). - If the struct is 16 bytes or smaller (e.g.
Term(u64)+bool), the parameter is shown correctly. - Adding
let r = &res;and inspectingrshows correct values. - Same behaviour with cpptools and with CodeLLDB. In my real project CodeLLDB reports "no location, value may have been optimized out" for the parameter.
Results by toolchain
| Toolchain | Result |
|---|---|
| 1.98.0 | OK |
| 1.99.0 | broken |
| 1.100.0 | broken |
beta (release: 1.101.0-beta.2;commit-date: 2026-11-12) |
broken |
nightly (release: 1.102.0-nightly;commit-date: 2026-11-20) |
broken, res missing from Locals |
| nightly-2026-07-04 | OK |
| nightly-2026-08-03 | OK |
| nightly-2026-08-06 | broken |
cargo bisect-rustc --by-commit points at:
Regression in 1b29cfdbee8ee37333f4b24afb936350eb57e705
which is the merge of #158734 ("Update to LLVM 23"). I re-verified this by launching the prebuilt executables from the bisect output folders, without rebuilding.
Environment
- Windows 11 Pro,
x86_64-pc-windows-msvc - MSVC linker 14.44.35207 (Visual Studio Build Tools 2022)
- VS Code :
Version: 1.135.0 (system setup)
Commit: 08d4889f9ec4a1685d257b9b95de036c8e1ce1e5
Date: 2026-08-25T14:26:52Z
OS: Windows_NT x64 10.0.26300 - cpptools :Version 1.35.6
, CodeLLDBIdentifier vadimcn.vscode-lldb Version 1.12.3 - Same result before and after uninstalling Visual Studio 2026 (which had toolset 14.51), so the linker version does not seem to matter.
Notes
I have not investigated the cause. Since the regression lands together with the LLVM update and shows up the same in two different debuggers, I suspect the location emitted in the PDB for indirectly passed parameters, but this is a guess. I am happy to test patches or other toolchains.
Workaround
let res_dbg = &res;at the start of the function, then inspect res_dbg.
@rustbot label +A-debuginfo +O-windows-msvc +regression-from-stable-to-stable
Activity
ChrisDenton commentedon Nov 21, 2026
cc @Walnut356
Walnut356 commentedon Nov 21, 2026
hmm, I have a hunch this is an issue I ran into when deciding which LLDB versions to support for the test suite a few months ago. IIRC LLVM 23 outputs a different PDB node than it used to, and LLVM/LLDB didn't know how to read that node prior to v23.
I'll look around for the thread. In the meantime, does LLDB 23+ (e.g. via
lldb-dap) work correctly?Walnut356 commentedon Nov 21, 2026
Stable 1.100
#161657 (comment) is where it was discussed.
Here is an
llvm-pdbutils dump --symbolsof the example program'shandlefunc:I was also able to debug it with lldb 23.1.4 via lldb-dap, so it looks like it's the same problem.
I couldn't replicate the issue with rust 1.100 codelldb 1.12.3 (which uses a modified version of lldb 22.1.8 internally). If possible, can you test again but with a
cargo cleaninbetween each build? Sometimeslink.exekeeps around stale info, even with all incremental options disabled (side note: maybe cargo should automatically delete the PDB file to avoid this issue?)I did observe the problem with
cpptools. Unfortunately, Microsoft's tools being non-compliant with Microsoft's debugging format isn't unusual (1, 2) Hopefully now that LLVM is outputting that node, it puts pressure on Microsoft to fix it.1.102.0-nightly (f93c676e3 2026-11-15)
I think this is a different issue. Here's the
llvm-pdbutildump ofhandle:pclaudiuc commentedon Nov 22, 2026
Thanks for looking into this, and sorry for the incomplete CodeLLDB claim in my original report. I re-tested everything with a full clean before each build (
Remove-Item -Recurse -Force target, thencargo +<version> build), using the same minimal example, on Windows 11 (build 10.0.26300),x86_64-pc-windows-msvc, MSVC linker 14.44.35207.CodeLLDB 1.12.3
res = <no location, value may have been optimized out>res = <no location, value may have been optimized out>cpptools 1.35.6 (cppvsdbg, vsdbg 17.13.20115.1)
res = {term={__0=???} ok=??? a=??? ...}With cpptools there is an additional problem. With a breakpoint on the
if res.okline and the Locals panel open, the debug session terminates as soon as I step past that line (res = Cancelledflashes in the panel just before it closes).Details from the debug adapter log (
engineLogging, rustc 1.99.0 b940084):Symbols loaded.) and the breakpoint is verified.variablesrequest for Locals is answered withres = {term={__0=???} ok=??? a=??? ...}.next,stackTraceandscopesfor the new location are answered normally, but the followingvariablesrequest for Locals gets no response, and the session ends.If I close the Locals panel (and have no Watch expressions), I can step through the whole function and run to the end without the session terminating. So it is the evaluation of the by-value parameter
resthat kills the session, not stepping itself. I only ran this check on 1.99.0.Summary
With clean builds, both debuggers fail on 1.99.0 and 1.100.0 and work on 1.98.0, the last toolchain before the LLVM 23 update:
This is consistent with the new
S_DEFRANGE_REGISTER_REL_INDIRrecord not being handled by LLDB < 23 and vsdbg, but I have not verified that myself. I can also testlldb-dapwith LLDB >= 23, or other tools, if that is useful.cppvsdbg adapter log (trimmed, rustc 1.99.0 b940084)
Bind a reference at the start of the function and inspect that instead:
Walnut356 commentedon Nov 22, 2026
Ah, the CodeLLDB issue is because of the
use native PDB Readersetting. If you turn that off, LLDB uses microsoft'sMSDIAto parse the PDB data, and that manages to extract the variable location correctly. Definitely weird thatmsdia.dllcan handle it butcpptoolscan't, but again it's not the first time Microsoft's tools have done something like that lolIn any case, the underlying codelldb issue is that codelldb needs to update their underlying LLDB version. Not much we can do there.
The issue on nightly looks like a bigger deal, since entire blocks and variables aren't being output at all. I'll take a closer look into it.
Walnut356 commentedon Nov 22, 2026
Ah, the issue is probably rust-lang/cargo#17518
in short,
devprofile outputs stripped down debug info. To get the same behavior as before, you need to build withcargo build --profile debugpclaudiuc commentedon Nov 22, 2026
Thanks, that explains the nightly result. I re-tested the nightly with
cargo +nightly build --profile debug(the rustc invocation shows-C debuginfo=2; the PDB contains the nightly's commit hashc7d5ba59d8e1...; rustc 1.102.0-nightly (commit-date 2026-11-20), LLVM 23.1.6; same minimal example, clean build):resis listed with unreadable fields (???), same as on 1.100.0SymbolFile native-pdb)res = <no location, value may have been optimized out>diareaderresdisplayed correctlySo with full debuginfo the nightly behaves like 1.100.0: the LLVM 23 related problem is not fixed there.
With the plain
devprofile (cargo +nightly build -v) the rustc invocation has-C debuginfo=line-tables-only, which explains whyreswas missing from Locals entirely on nightly in my earlier test. That part is not a rustc/LLVM issue, so the "nightly" row in my original results table should be disregarded.