Skip to content

test(m2-10): integrated campaign, coverage, and two scheduler/sanitizer fixes - #38

Merged
teo1747 merged 6 commits into
feat/m2-09-dworkfrom
test/m2-10-campaign
Oct 30, 2026
Merged

teo1747 merged 6 commits into
feat/m2-09-dworkfrom
test/m2-10-campaign

Conversation

@teo1747

@teo1747 teo1747 commented Oct 30, 2026

Copy link
Copy Markdown
Member

Stacked on #37. This completes the first two M2-10/M2-11 checklist items: the combined campaign, and the misuse, property, sanitizer and coverage results.

Problem and result

M2-10 asks for mechanisms combined at section boundaries under adversarial interrupt and tick placement, plus sanitizer runs and statement and branch coverage with real case identity. Disclosed gaps are acceptable; unexplained failures are not.

  • Combined scenarios. The COMBINED model group has six scenarios. Each pairs a primitive with cancel, suspend, destroy, a priority change, bindings, or timer and work callbacks.
  • Two kernel defects found and fixed. Each has its own commit.
    • Missing preemption. Raising a ready thread's priority above the caller with emb_thread_set_priority() did not preempt: the caller kept running until its next block or yield. The new case sched_raising_a_ready_thread_above_the_caller_preempts fails on the old kernel and passes on every target.
    • AddressSanitizer on macOS. It could not run the suites: Clang pads Mach-O section globals, so the test and init table walks read padding as entries. Table entries now opt out, and native-asan passes 20/20 locally.
  • Coverage. A native-coverage preset plus tools/coverage/report.py. The native port now dumps gcov counters before _exit(), which otherwise skips the flush. CI builds the preset, publishes the report and tests the report tool.
  • Campaign runner. tools/model/campaign.py runs the whole catalogue over runners and seeds, plus the timer regressions, and writes summaries with build identities.
  • Evidence and report. Archived under tools/model/evidence/m2-10/; the report is docs/engineering/m2-10-campaign.md.

Validation

  • Campaign. Seeds 1–10, --runs 40, plus the regressions, on a clean tree at f563ef5:

    Runner Runs Agree Regressions
    native-gcc 33,600 33,600 5/5
    native-clang 33,600 33,600 5/5
    native-periodic 33,600 33,600 5/5
    native-release 33,600 33,600 5/5
    native-tiny 24,400 24,400 4/4

    158,800 runs, no divergence.

  • Every local configuration passes.

    • Native: gcc, release, periodic and clang 20/20; tiny 17/17.
    • Sanitizers and coverage: native-asan, native-tsan and native-coverage 20/20; tiny ASan 17/17.
    • QEMU: cm3 17/17; cm4 and -release 18/18; cm4-tiny 15/15; rv32 and -release 17/17; rv32-tiny 14/14.
    • AVR: avr-uno and -release 14/14; t1 11/11.
    • EmbSIM: uno 14/14, nucleo 18/18, c3 17/17.
  • Coverage. 91.4% of 2,900 kernel lines and 72.5% of 1,472 branches, over all 18 base-build kernel files; nothing is excluded. The report explains the lowest-covered files.

  • Requirement matrix. No failed case in any configuration. 127 of 377 requirements have a passing executed case.

    • KRN-IPC-021 gained one in this PR.
    • KRN-IPC-022 and KRN-WQ-011 stay verified by analysis and trace only, as their cards say.
  • Model. 122 model tests pass.

  • Footprint. T1 is unchanged (4,056 / 39 / 32).

  • Lint and docs. Docs tests OK; the local docs build shows the same nine shim warnings; banned-pattern check 0 findings; clang-format clean.

  • Not run. Hardware-in-the-loop and physical timing (no board), and the EmbCC native flow.

Review checklist

  • Each authored commit has my matching Signed-off-by trailer (git commit -s); DCO is separate from cryptographic signing.
  • Scope and implementation limits are reflected in the user/API documentation and Project status where applicable.
  • Contract changes update requirements/specifications; architecture decisions have an ADR. (No contract change: two defect fixes.)
  • Kernel semantics changes update the reference model and conformance evidence in the same PR.
  • User-visible changes have an Unreleased changelog entry, or Validation explains why none is needed.
  • Required checks pass, review conversations are resolved, and known failures are disclosed before merge.

…unner

- The COMBINED scenario group meets several mechanisms at section
  boundaries, with ISR and tick placement left to the explorer and the
  bridge:
  - a suspended, canceled and resumed message queue receiver against an
    ISR send;
  - an inheriting owner's priority change against an event wait's timeout
    and an ISR set;
  - a timed take against a give and destroy at the same ticks;
  - one thread bound to a message queue and to event flags;
  - an ISR-context timer feeding a queue a work handler reads while the
    thread flushes and stops it;
  - an ISR cancel racing a delayed item's expiry.
- native-coverage preset: GCC with --coverage at -O0. The native port
  dumps the gcov counters before _exit(), which skips the exit-time
  flush.
- tools/coverage/report.py: kernel statement and branch coverage from
  gcov or llvm-cov gcov, with file exclusions and their reasons.
- tools/model/campaign.py: runs the bridge over runners and seeds plus
  the timer regressions and writes a JSON summary with the build
  identities.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>
…once

embk_sched_prio_changed() set reschedule_pending only when the running
thread's own effective priority fell below a ready thread. When another
thread raised a ready thread above the caller with
emb_thread_set_priority(), nothing marked the reschedule, and the caller
kept running past its preemption point until its next block or yield.

The M2-10 combined campaign found it: in release builds, where the
scenario's owner-death policy lets the run continue, a raised owner did
not run before the raising thread's next wait. The hook now marks the
reschedule when a ready thread other than the running one rises above
it. The new case sched_raising_a_ready_thread_above_the_caller_preempts
fails on the old kernel (marks 1, 3, 2) and passes now.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>
…izer

Clang's AddressSanitizer on Mach-O pads globals in custom sections with
redzones, so walking the test or init table read the padding as
entries. Every conformance suite aborted with a global-buffer-overflow
in the runner, and native-asan could not run on macOS. ELF builds leave
section globals alone, which is why CI passed.

Table entries now carry EMB_TABLE_ENTRY_ATTR: no_sanitize("address")
under Clang with AddressSanitizer, empty everywhere else. native-asan
passes 20/20 locally and the tiny ASan build 17/17.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>
Signed-off-by: teo1747 <motsoujunior17@gmail.com>
The previous fix marked the reschedule in the scheduler's priority hook,
which the inheritance recomputation calls. A build without mutexes,
such as the tiny footprint configuration, sets the effective priority
directly and never reaches that hook, so
sched_raising_a_ready_thread_above_the_caller_preempts still failed on
avr-uno-t1. emb_thread_set_priority() now checks the raised thread
against the running one itself.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>
- tools/model/evidence/m2-10/: the campaign summaries for native gcc,
  clang, periodic, release and tiny (seeds 1-10, --runs 40, plus the
  timer regressions): 158,800 runs, no divergence, clean tree at
  f563ef5. Also the kernel coverage (91.4% of lines, 72.5% of branches,
  nothing excluded) and the requirement-matrix summary over all 21
  configurations.
- docs/engineering/m2-10-campaign.md reports the combined scenarios,
  the two defects the campaign found (the missing preemption on a
  priority raise and the macOS AddressSanitizer table padding), the
  sanitizer results, the lowest-covered files, and the implemented
  requirements verified by analysis rather than by a case.
- CI builds native-coverage, publishes the report and runs the report
  tool's tests. The sanitizer and coverage configurations join the
  evidence catalogue.
- msgq_small_counts_refuse_a_capacity_above_255 gives KRN-IPC-021 an
  executed case.
- The checklist's two campaign items, STATUS and the changelog are
  updated.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>
@teo1747 teo1747 mentioned this pull request Oct 30, 2026
5 of 6 tasks
@teo1747
teo1747 merged commit dd4b9c0 into feat/m2-09-dwork Oct 30, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant