Skip to content

moq-mux: catalog::Producer::new panics when the system clock is before 2020, and panic = "abort" turns that into a host crash #5407

Closed

Description

@pwrwpw

Problem

catalog::Producer::new falls back to Clock::default() when Config carries no clock. Clock::new() then unwraps a fallible constructor, so a wall clock before the moq epoch (2020) panics. With panic = "abort" the panic aborts the whole host process instead of reaching the catch_unwind in the FFI layer.

At 6e97bd16d:

  • rs/moq-mux/src/catalog/producer.rs:364: config.clock.unwrap_or_default() runs on every Producer::new without an explicit clock.
  • rs/moq-mux/src/clock.rs:87: Clock::new() is Self::arrival(Self::LEAD).expect("the current wall time is representable as a broadcast clock").
  • rs/moq-mux/src/clock.rs:44: wall_clock() refuses any time before 2020 ("A time before 2020 cannot be named on the wire; refuse it rather than advertise 2020"), so arrival() returns Err and the expect panics.
  • rs/moq-c/src/ffi.rs:42: every FFI call is wrapped in catch_unwind and a panic maps to Error::Panic, so the intent is that a library panic does not take the host down.
  • Cargo.toml:255 and :313: both [profile.dev] and [profile.release] set panic = "abort", so that catch_unwind never runs.
  • Both FFI entry points reach this path: rs/moq-c/src/publish.rs:106 and rs/moq-ffi/src/producer.rs:141.

An invalid wall clock is an ordinary state on embedded devices. Many boards have no battery-backed RTC, or one that was reset, so the wall clock stays at its default epoch until NTP or the network sets it. A publisher that starts at boot, before time sync, hits this path.

Measured behavior

On an Android (arm64) device with no valid time yet at boot, publishing started before time sync and the host app's process died with SIGABRT. The library was built from tag libmoq-v0.6.13.

  • The tombstone's abort message is only a prefix from the host app, but the register dump holds the ASCII of the expect message (the curr ent wall ...).
  • Symbolizing against the matching build (same Build ID) puts the abort frame inside the moq_net::ietf::publisher::...::sync_namespace closure. Those frames are inlined, so I treat that location as approximate. The message string identifies the site: it appears at clock.rs:82 of that tag.
  • Once the clock was set, the crash no longer reproduced.

Why a small fix is not obvious

Possible approaches

  1. Make Producer::new return moq_mux::Error and build the default clock with Clock::arrival(Clock::LEAD)? instead of unwrap_or_default(). The FFI crates already convert moq_mux::Error, so the failure reaches the caller as an error code. This is a breaking signature change.
  2. Add a fallible Clock::try_new() (keeping new() as expect for callers that cannot fail) and validate the wall time in Config before Producer::new. Less churn at call sites, but the validation and the construction are two steps.
  3. Keep the behavior and document that Producer::new panics on a pre-2020 clock. The FFI hosts would have to check the system time themselves.

Separately, with panic = "abort" the catch_unwind in ffi.rs does not run in any build, so it cannot turn a panic into Error::Panic. If abort is intentional for the FFI crates, that catch_unwind could be removed or documented

I can send a PR for (1) or (2). Since (1) is breaking, I'd like your call before opening it.

Related: #3675 introduced the catalog-root clock and the 2020 epoch.

(Written by Claude Opus 5.5)

Activity

  1. kixelated commented on Oct 13, 2026

    @kixelated
    Collaborator

    lul okay I thought 2020 would be safe as an epoch, as a way of saving a few more bytes.

  2. added
    questBeing tracked/planned in a quest. See `quest/`
    on Oct 13, 2026
  3. kixelated commented on Oct 13, 2026

    @kixelated
    Collaborator

    Thanks for the detailed report; confirmed on main.

    Decision (planned in #5418):

    • Keep the 2020 epoch, and make the wall mapping optional instead of fallible. On a host whose clock reads before 2020, Clock::new() stays infallible, and the catalog omits the root clock, which is already optional on the wire. Media still publishes. A pre-2020 reading means the clock is unset. Omitting it beats advertising a false mapping: DASH falls back to the relay's anchor instead of a 1970 availabilityStartTime. Producer::new keeps its signature. Clock::wall() returns Option, and anything that actually needs a wall errors. @moq/publish gets the same treatment. Tracked by quest/m0/wall-clock-omit.
    • It gets backported to the 0.17 / libmoq 0.6.x line as a cherry-pick (quest/m0/release-22/wall-clock-omit), which closes this issue.
    • On panic = "abort": we're switching the workspace to unwind, so a panic closes only its connection and FFI hosts get MOQ_ERROR_PANIC / an exception instead of dying. Lock poison will be ignored at shared locks, and every spawned task will be supervised, so a long-lived task's panic still exits loudly rather than leaving a zombie. Tracked by quest/m0/panic-isolation.

    Once #5418 merges, anyone who wants to donate tokens can pick one up with /quest-start quest/m0/wall-clock-omit (or quest/m0/panic-isolation). Your offer of a PR is welcome too, following the plan in the quest file.

    (Written by Claude Opus 5.5)

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

    questBeing tracked/planned in a quest. See `quest/`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions