Skip to content

debug-check (check 20): gdb round trip; findings 33-34 (gdb printers) - #37

Merged
zmaril merged 1 commit into
mainfrom
mirth/check-debugger
Oct 10, 2026
Merged

zmaril merged 1 commit into
mainfrom
mirth/check-debugger

Conversation

@zmaril

@zmaril zmaril commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Check 20 of docs/checks.md, the debugger round trip, as mirth-lab debug-check.

What it does

Each seed generates a program that builds known values. gdb, loaded with rust-gdb's pretty-printers, stops at a breakpoint and prints every local, plus *v for boxes and references. Each command runs as its own -ex, under a timeout. The output is parsed into a tree and compared structurally with the values the generator built, at -Copt-level 0, 1 and 2. At levels 1 and 2 an optimized-out value is accepted; a wrong value never is.

The values cover:

  • integers of every width, and floats built from bit patterns (signed zeros, infinities, NaN payloads, subnormals)
  • chars and strings with escapes and non-ASCII
  • arrays, slices, Vec, VecDeque built to wrap around, and the four maps and sets
  • Option and Result, including niche-optimized cases
  • Box, Rc and Arc with known strong and weak counts, Weak, RefCell with live Ref/RefMut guards, Cell
  • generated structs, tuple structs, unit structs, enums (with data, and fieldless with a repr and explicit discriminants), and unions
  • references, PhantomData, OsString, Box<str>, Box<[T]>, Rc<str>, Arc<[T]>, PathBuf
  • large vectors, and an Rc cycle, which must terminate

Results: 4,000 programs × 3 opt levels

Two findings, both in src/etc/gdb_providers.py. Both reproduce from 1.80.0 through nightly-2026-10-06, and no existing issue turned up for either.

  • Finding 33:
    • The Vec, VecDeque and slice printers raise exceptions on zero-sized elements: "Cannot perform pointer math on incomplete type", and % cap where the stored capacity is 0.
    • BTreeMap and BTreeSet show every zero-sized key or value as (), whatever its type.
  • Finding 34: the Ref/RefMut printer fails on every guard. It dereferences the NonNull field without unwrapping it, so neither the borrowed value nor the borrow count is shown. No gdb test prints a Ref.

Four more classes are gdb's own behaviour. They are labelled as expected, with the facts in docs/checks.md:

  • gdb 15 can't read a 128-bit enum discriminant.
  • An array of zero-sized elements prints as an address.
  • A struct ending in a zero-sized field is taken for an unsized one, which breaks Box<[Arc<T>]>.
  • An optimized-out pointer to an enum is read through at address 0.

Nothing else showed up: no other wrong value, no hang, no gdb crash.

Facts are in docs/hunt/gdb-printers.md, and the reductions in docs/hunt/tests/debug-check/. rustc/big-run.sh now runs this check too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QXiEXbESemwqMLYKaWLDbT

…es a program defines; findings 33 and 34

Seeded programs build known values of std and user types; gdb prints every local (and *v
for boxes and references) at a breakpoint, one -ex each, under a timeout; the output is
parsed into a tree and compared structurally with the generator's values, at -Copt-level
0, 1 and 2 (optimized out accepted above 0). gdb's own limitations are labelled expected.

4,000 programs x 3 levels: finding 33 (Vec/VecDeque/slice printers on zero-sized elements:
pointer math on an incomplete type, % 0; BTreeMap shows () for every zero-sized key or
value) and finding 34 (the Ref/RefMut printer dereferences the NonNull field without
unwrapping it); nothing else.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QXiEXbESemwqMLYKaWLDbT
@zmaril
zmaril merged commit a1c9adf into main Oct 10, 2026
0 of 3 checks passed
@zmaril

zmaril commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Merged into main together with #33–#38; renumbered at merge so finding numbers are unique: findings 33–34 are now 48–49 (docs/hunt.md).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant