Skip to content

Proposal: implement complete synctest bubble semantics #2131

Description

@cpunion

Background

LLGo currently provides minimal internal/synctest hooks that report no active bubble. PR #2098 adds the Go 1.26 acquire, release, and inBubble hooks with the same no-bubble behavior so ordinary standard-library code can link and run. This is sufficient when no testing/synctest bubble is active, but it is not an implementation of synctest.

What a synctest bubble means

A bubble is an isolated logical test environment containing related goroutines, timers, and synchronization objects. The Go runtime uses it to make concurrent tests deterministic:

  • bubble time is fake and advances only when all bubble goroutines are durably blocked
  • Wait returns only after the bubble reaches a stable blocked state
  • goroutines and supported synchronization objects are associated with one bubble
  • operations that improperly cross bubble boundaries are rejected
  • acquire and release keep a bubble active across asynchronous work
  • inBubble temporarily executes a callback in the captured bubble

Returning nil from acquire is correct only for code running outside a bubble. It cannot support testing/synctest.Run or Wait semantics.

Proposal

Design the LLGo equivalent around its scheduler and timer model:

  • per-goroutine bubble identity and lifetime
  • active and durably-blocked accounting
  • fake-clock ownership and timer advancement
  • block and wake classification for channels, mutexes, condition variables, timers, sleep, and supported I/O paths
  • association metadata and cross-bubble checks for synchronization objects
  • propagation through async callbacks using acquire, release, and inBubble
  • cancellation, panic, nested-call, and cleanup semantics matching the supported Go version

LLGo uses a different execution model from the Go g/m/p scheduler, so copying only the public hook bodies is insufficient. The proposal must identify equivalent scheduler transition points before implementation.

Versioning

The implementation and compatibility tests must be pinned to the supported Go toolchain version because internal/synctest is private and can change between Go releases. Upgrades should update the implementation and tests together.

Acceptance criteria

  • run representative testing/synctest tests for fake time, durable blocking, and Wait
  • cover channel, mutex, condition, timer, sleep, and callback propagation behavior
  • cover invalid cross-bubble operations and cleanup after panic
  • keep the no-bubble fast path behavior used by ordinary programs and C libraries
  • add platform coverage wherever LLGo scheduler or timer behavior differs

Related: #2088, #2098

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions