test: cmark memory/leak/concurrency/multibyte-position safety harness - #9
Merged
Conversation
…ness Adds four test files that close the blind spots in the existing suite ahead of a possible CMNode wrapper-churn optimization: - MultibytePositionTests: byte-vs-character position correctness (emoji, CJK, accents, combining marks, ZWJ, CRLF, tabs); asserts input[range] substrings. - MemorySafetyTests: retained nested nodes outlive the owning document, iterator enumerate/reset, tight re-parse and wrapper-graph churn loops (run under ASan). - LeakTests: weak-reference cycle checks + bounded-growth loops. - ConcurrencyTests: hundreds of concurrent parses, same/different inputs (run under TSan). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Guards the hand-rolled cmark memory model with ASan/TSan on every PR, so a future CMNode wrapper-churn optimization that introduces a use-after-free, double-free, leak, or data race is caught in CI. Sanitizer steps run after the coverage step so they don't clobber its profraw data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 137 133 -4
=========================================
- Hits 137 133 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Adds a test-and-tooling-only safety net around the
cmark_gfmwrapper, with no production code changes. This hardens coverage of the failure modes that the current suite is structurally blind to, so a future performance change toCMNode(reducing wrapper-object allocation) can be made safely.What's added
MultibytePositionTests— byte-vs-character position correctness (emoji/CJK/combining/ZWJ/CRLF/tabs), asserted at the substring level.MemorySafetyTests— retained nodes outliving the document,Iteratorreset/re-enumerate, tight re-parse and wrapper-graph churn loops.LeakTests— retain-cycle weak-ref checks + bounded-growth loops.ConcurrencyTests— hundreds of concurrent parses (same/different inputs).Results
swift test, ASan, and TSan — zero sanitizer diagnostics.Findings
utf8.index-based position mapping is already byte-correct; the old tests only used ASCII (input.range(0...N)), where char- and byte-offsets coincide, so multibyte was untested — now closed.ParserInlineTests.testInvalidLinkcrashes locally (index-out-of-range on an unexpected parse shape) but is gated byXCTSkipIf(isCI), so CI stays green; it awaits an upstream swift-cmark fix.Purpose
Prerequisite for a later, guarded
CMNodewrapper-allocation reduction: the three ownership-break failure modes are now watched by sanitizers on every PR (a dropped owner → ASan use-after-free; a leaked node/cycle → LeakTests + ASan; shared mutable wrapper state → TSan race). Not covered: allocation/perf baselines (safety only, not churn magnitude).🤖 Generated with Claude Code