fix(libmoq): update tests for moq_origin_publish handle return#1710
Merged
Conversation
`moq_origin_publish` was changed in #1640 to return a positive publish handle (paired with `moq_origin_unpublish`) under the RAII OriginPublish model, but the libmoq tests still asserted it returned 0. The staleness went unnoticed because CI's `cargo check --all-features` failed to compile (NVENC) since #1691, so these tests never ran. The failed `== 0` assertion panicked each test mid-flight, dropping the test's Callback (freeing user_data) without draining the terminal callback, so the still-alive background task fired into freed memory: a SIGSEGV under the test harness. The callback contract itself (free user_data once, in the final terminal callback) was already correct. Capture the handle with `id()` (which still checks it is positive) at every call site. `announced_deactivation` deactivated by closing the broadcast, but dropping the producer no longer unannounces under the OriginPublish model, so it now deactivates via `moq_origin_unpublish` instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kixelated
enabled auto-merge (squash)
June 13, 2026 05:49
kixelated
disabled auto-merge
June 13, 2026 14:34
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cargo test -p libmoq --all-featureswas crashing with a SIGSEGV (signal 11) and a non-unwinding panic. The failing tests (local_announce,catalog_update_on_new_track,announced_deactivation,consume_announced_local,double_close_all_resource_types, and others) all panicked first on an assertion likeassert_eq!(moq_origin_publish(...), 0).Root cause: stale tests, not a callback bug. #1640 changed
moq_origin_publishto return a positive publish handle (paired with the newmoq_origin_unpublish) under the RAIIOriginPublishmodel, but never updatedrs/libmoq/src/test.rs, which still asserted a0return. This went unnoticed because CI'scargo check --workspace --all-featuresfailed to compile (NVENC) since #1691, socargo test --all-featuresnever actually ran until the moq-video CI plumbing was fixed in #1704.Why it segfaulted. The failed
== 0assertion panicked each test mid-flight, which dropped the test'sCallback(freeinguser_data) without draining the terminal callback viarecv_terminal(). The still-alive background announce/catalog task then fired its callback into freed memory: a use-after-free → SIGSEGV. The terminal-callback contract in the production code (freeuser_dataexactly once, in the final callback) was already correct (#1546) and is unchanged.Changes (test-only)
id()(which still asserts it is positive) at all 10 call sites, instead of asserting== 0.announced_deactivationpreviously deactivated by closing the broadcast producer. Under theOriginPublishmodel, dropping the producer no longer unannounces, so it now deactivates viamoq_origin_unpublish(publish)and closes the broadcast at the end.Test plan
cargo test -p libmoq --all-features— 23 passed, 0 failed, no abort (run 3×, repeatable)cargo test -p libmoq(default features) — 23 passedcargo fmt -p libmoq --check— cleancargo clippy -p libmoq --all-features— cleanNo public API or wire behavior changes (test-only). Targets
dev, since themoq_origin_publishhandle change (#1640) and the CI fix that surfaced this (#1704) both live there.(Written by Claude)