Skip to content

Rethink debug lifecycle #1210

Open
0 of 4 issues completed
Open

Description

@syntactically

Currently, the initial breakpoint set up when creating a sandbox is set on the entrypoint function, which means that, when creating a sandbox from an initialised snapshot, it is never set up or executed, and a debugger has no easy way to attach.

Relatedly, the debugging infrastructure (and the initial breakpoint) is/are set up in Sandbox::new(), which means that whether a sandbox has a debug thread or not is decided once, at sandbox creation time, but there is also only one place to attach a debugger (at sandbox initialisation time): future function calls, or restored sandboxes, might not be easy to debug, even though they have a debug thread consuming resources.

See also: this comment

Activity

  1. ludfjig commented on Feb 4, 2026

    @ludfjig
    Contributor

    Note that #1120 might further change debugging due to resetting debug register on snapshot-restores, which could potentially discard breakpoints etc. One possible solution might be to not reset debug registers if gdb cargo feature is enabled?

  2. added
    lifecycle/confirmedBug is verified or proposal seems reasonable
    and removed on Feb 25, 2026
  3. added this to the v0.15.0 milestone on Feb 25, 2026
  4. dblnz commented on Feb 25, 2026

    @dblnz
    Contributor

    This is a note to think about the future of debugging a sandbox.
    Currently, we rely on the entrypoint function breakpoint to allow the user the time to add new breakpoints, but if a sandbox has been snapshotted after the initialise phase, that won't work.

  5. simongdavies commented on Feb 25, 2026

    @simongdavies
    Member

    Additionally we may want to consider that restore/resetting a sandbox might work very differently as we move towards using Snapshots as the basis for creating Sandboxes

  6. modified the milestones: v0.15.0, Backlog on Jun 17, 2026
  7. ludfjig commented on Oct 22, 2026

    @ludfjig
    Contributor

    Status on current main:

    • Snapshot attach is partly solved. Since Create sandboxes directly from snapshots #1459, HyperlightVm::new sets the one-shot breakpoint at the next entry, so sandboxes from initialised snapshots stop at the first call. restore() does not set it again.
    • One session per sandbox, fixed at creation, still holds. The gdb thread accepts once. After a detach no client can attach again.
    • The concern from Reset more vcpu state on snapshot::restore #1120 holds on MSHV and WHP. reset_vcpu zeroes the debug registers, and those hypervisors keep gdb hardware breakpoints there. KVM keeps them in kvm_guest_debug, so they survive.

    Sub-issues:

    Remaining design question: when should a gdb client be able to attach? Options:

    • Only at the first entry, as today.
    • At the next guest call whenever no client is connected, using a non-blocking accept.
    • Behind an opt-in "break on every call" setting.
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

    lifecycle/confirmedBug is verified or proposal seems reasonable

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions