Skip to content

Debuginfo regression on x86_64-pc-windows-msvc since the LLVM 23 update (#158734): by-value parameters larger than 16 bytes are unreadable or missing in the debugger #166324

Open

Description

@pclaudiuc

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

  1. cargo build
  2. In VS Code, set a breakpoint on the if res.ok line and launch target\debug\<name>.exe with cpptools (cppvsdbg) or CodeLLDB, without rebuilding.
  3. Look at res in Locals.

Expected

res and its fields show their values (ok = true, a = 1, ...).

Actual

  • Affected toolchains (1.99.0, 1.100.0, beta): res is listed, but its fields show <Unable to read memory> / ???, even plain u64 fields.
  • Current nightly: res is 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 inspecting r shows 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
    , CodeLLDB Identifier 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

  1. added
    C-bug
    regression-untriaged
    on Nov 21, 2026
  2. added
    needs-triage
    I-prioritize
    A-debuginfo
    O-windows-msvc
    regression-from-stable-to-stable
    on Nov 21, 2026
  3. ChrisDenton commented on Nov 21, 2026

    @ChrisDenton
    Member
  4. Walnut356 commented on Nov 21, 2026

    @Walnut356
    Contributor

    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?

  5. Walnut356 commented on Nov 21, 2026

    @Walnut356
    Contributor

    Stable 1.100

    #161657 (comment) is where it was discussed.

    Here is an llvm-pdbutils dump --symbols of the example program's handle func:

       488 | S_LPROC32 [size = 56] `sample::handle`
             parent = 0, end = 640, addr = 0001:0464, code size = 47
             type = `0x107A (unsigned __int64 (sample::Res))`, debug start = 0, debug end = 0, flags = opt debuginfo
       544 | S_FRAMEPROC [size = 32]
             size = 16, padding size = 0, offset to padding = 0
             bytes of callee saved registers = 0, exception handler addr = 0000:0000
             local fp reg = RSP, param fp reg = RSP
             flags = safe buffers
       576 | S_LOCAL [size = 16] `res`
             type=0x1070 (sample::Res), flags = param
       592 | S_DEFRANGE_REGISTER_REL_INDIR [size = 28]
             register = RSP, offset = 0, offset in udt = 0, offset in parent = 0, has spilled udt = false
             range = [0001:0472,+39), gaps = [(0,4)]
       620 | S_DEFRANGE_REGISTER_REL [size = 20]
             register = RCX, offset = 0, offset in parent = 0, has spilled udt = false
             range = [0001:0472,+4), gaps = []
       640 | S_END [size = 4]
    

    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 clean inbetween each build? Sometimes link.exe keeps 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-pdbutil dump of handle:

       376 | S_LPROC32 [size = 56] `sample::handle`
             parent = 0, end = 464, addr = 0001:0320, code size = 47
             type = `0x1001 (void ())`, debug start = 0, debug end = 0, flags = opt debuginfo
       432 | S_FRAMEPROC [size = 32]
             size = 16, padding size = 0, offset to padding = 0
             bytes of callee saved registers = 0, exception handler addr = 0000:0000
             local fp reg = RSP, param fp reg = RSP
             flags = safe buffers
       464 | S_END [size = 4]
    
  6. added
    T-dev-tools
    A-debuggers
    and removed
    regression-untriaged
    needs-triage
    on Nov 21, 2026
  7. pclaudiuc commented on Nov 22, 2026

    @pclaudiuc
    Author

    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, then cargo +<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

    Toolchain Result
    1.98.0 OK
    1.99.0 res = <no location, value may have been optimized out>
    1.100.0 res = <no location, value may have been optimized out>

    cpptools 1.35.6 (cppvsdbg, vsdbg 17.13.20115.1)

    Toolchain Result
    1.98.0 OK
    1.99.0 res = {term={__0=???} ok=??? a=??? ...}
    1.100.0 same as 1.99.0

    With cpptools there is an additional problem. With a breakpoint on the if res.ok line and the Locals panel open, the debug session terminates as soon as I step past that line (res = Cancelled flashes in the panel just before it closes).

    Details from the debug adapter log (engineLogging, rustc 1.99.0 b940084):

    • The PDB loads fine (Symbols loaded.) and the breakpoint is verified.
    • At the first stop, the variables request for Locals is answered with res = {term={__0=???} ok=??? a=??? ...}.
    • After next, stackTrace and scopes for the new location are answered normally, but the following variables request for Locals gets no response, and the session ends.
    • No Application Error event was logged by Windows, so it does not look like an OS-recorded crash.

    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 res that 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:

    • CodeLLDB (LLDB 22.1.8 bundled): the parameter has no location.
    • cpptools / vsdbg: the parameter shows unreadable values, and evaluating it ends the session.

    This is consistent with the new S_DEFRANGE_REGISTER_REL_INDIR record not being handled by LLDB < 23 and vsdbg, but I have not verified that myself. I can also test lldb-dap with LLDB >= 23, or other tools, if that is useful.

    cppvsdbg adapter log (trimmed, rustc 1.99.0 b940084)
    -> setBreakpoints  main.rs, line 12
    <- response: breakpoint pending ("will be resolved when debugging starts")
    <- module: dbgtest.exe, symbolStatus "Symbols loaded.", symbolFilePath ...\target\debug\dbgtest.pdb
    <- breakpoint changed: verified=true, line 12
    <- stopped: reason=breakpoint, line 12
    -> stackTrace
    <- frame 0: "dbgtest.exe!dbgtest::handle(dbgtest::Res res) Line 12"  (remaining frames omitted)
    -> scopes (frameId 1000)
    <- scopes: Locals (1000), Registers (1001)
    -> variables (1000)
    <- {"name":"res","value":"{term={__0=??? } ok=??? a=??? ...}","type":"dbgtest::Res","variablesReference":1002}
    -> next
    <- continued
    <- stopped: reason=step, line 13
    -> stackTrace
    <- frame 0: "dbgtest.exe!dbgtest::handle(dbgtest::Res res) Line 13"  (remaining frames omitted)
    -> scopes (frameId 1000)
    <- scopes: Locals (1000), Registers (1001)
    -> variables (1000)
       (no response; the session ends here)
    
    ### Workaround

    Bind a reference at the start of the function and inspect that instead:

    let res_dbg = &res;
  8. Walnut356 commented on Nov 22, 2026

    @Walnut356
    Contributor

    Ah, the CodeLLDB issue is because of the use native PDB Reader setting. If you turn that off, LLDB uses microsoft's MSDIA to parse the PDB data, and that manages to extract the variable location correctly. Definitely weird that msdia.dll can handle it but cpptools can't, but again it's not the first time Microsoft's tools have done something like that lol

    In 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.

  9. Walnut356 commented on Nov 22, 2026

    @Walnut356
    Contributor

    Ah, the issue is probably rust-lang/cargo#17518

    in short, dev profile outputs stripped down debug info. To get the same behavior as before, you need to build with cargo build --profile debug

  10. pclaudiuc commented on Nov 22, 2026

    @pclaudiuc
    Author

    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 hash c7d5ba59d8e1...; rustc 1.102.0-nightly (commit-date 2026-11-20), LLVM 23.1.6; same minimal example, clean build):

    Debugger Result
    cpptools (vsdbg) res is listed with unreadable fields (???), same as on 1.100.0
    CodeLLDB 1.12.3, native PDB reader (SymbolFile native-pdb) res = <no location, value may have been optimized out>
    CodeLLDB 1.12.3, forced dia reader res displayed correctly

    So with full debuginfo the nightly behaves like 1.100.0: the LLVM 23 related problem is not fixed there.

    With the plain dev profile (cargo +nightly build -v) the rustc invocation has -C debuginfo=line-tables-only, which explains why res was 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuggersA-debuginfoC-bugI-prioritizeO-windows-msvcT-dev-toolsregression-from-stable-to-stable

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions