Skip to content

rust-lldb: Incorrectly display Option::None as Option::Some #152743

Description

@zzjrabbit

I am developing a kernel, and when I tried debugging with rust-lldb, I found this:

pm1b = Some({gas:{address_space:SystemMemory, bit_width:'\x99', bit_offset:'\0', access_size:'\0', address:234201088}, handler:(), mapping:Some({physical_start:18446603338569718192, virtual_start:{pointer:"APIC\x99"}, region_length:18446603338569718160, mapped_length:18446603336455397376, handler:()})}) {
    0 = {
      gas = {
        address_space = SystemMemory
        bit_width = '\x99'
        bit_offset = '\0'
        access_size = '\0'
        address = 234201088
      }
      handler =
      mapping = Some({physical_start:18446603338569718192, virtual_start:{pointer:"APIC\x99"}, region_length:18446603338569718160, mapped_length:18446603336455397376, handler:()}) {
        0 = {
          physical_start = 18446603338569718192
          virtual_start = {
            pointer = 0xffff80000df5a000 "APIC\x99"
          }
          region_length = 18446603338569718160
          mapped_length = 18446603336455397376
          handler =
        }
      }
    }
  }

While I unwrapped pm1b with the following code:

let pm1 = &registers.pm1_control_registers;
log::debug!("pm1: {:?}", pm1.pm1b.is_some());
loop {
    let pm1b = pm1.pm1b.as_ref();
    pm1b.unwrap().write((slp_typa | (1 << 13)) as u64).unwrap();
}

And there's the output.

[DEBUG] pm1: false, kernel_hal/src/platform/bare/acpi/power.rs:20
[ERROR] Panic: panicked at kernel_hal/src/platform/bare/acpi/power.rs:23:14:
called `Option::unwrap()` on a `None` value

What made me sure that this is a bug of rust-lldb is the length of the region, which is too large to be valid.
And I am using 1.95.0-nightly (ce69df6f7 2026-02-12) toolchain, while the version of lldb is 21.1.8 from nixpkgs.

Activity

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-debuggers-lldbArea: lldbC-bugCategory: This is a bug.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions