Interactive <google-codelab> · Best Codelab / Tutorial
Teach QPP to say no.
Diagnose three upstream gaps, apply patches/qpp-vss-warden.patch with zero fuzz, arbitrate .control writes from a POSIX shell, recover from a crashed holder, then prove P1–P3 with fast-check. Host replay uses C11 WASI; QNX SDP 8.0 dual-arch builds and QNX 8.0 QEMU execution are target-verified.
- Steps
- 05
- Duration
- ~26 min
- Toolchain
- clang · patch · echo / cat · npm test
Step 1 of 5 · 5 min
Diagnose the 3 Upstream QNX 8.0 QPP Safety & Correctness Gaps
Fetch the official QNX POSIX Publish Subscribe (QPP) source at b5ca892f into a local checkout and identify the 3 SDV safety and data-corruption gaps. Upstream licensing remains separate from this project's Apache-2.0 license.
Run
- $
bash scripts/fetch-qpp.sh .scratch/qpp-patched - $
sed -n '68,78p;432,448p' .scratch/qpp-patched/qpp/value.c - $
sed -n '50,64p' .scratch/qpp-patched/qpp/metadata.c - $
sed -n '75,92p' .scratch/qpp-patched/qpp/iowrite.c
Code & diagnostic output
/* Gap 1: qpp/value.c:73 & qpp/value.c:434-447 + qpp/metadata.c:54-59 */ // Upstream qpp/value.c:73 caps VECTOR_UINT32 at UINT16_MAX (65535) with 2-byte element size: [VECTOR_UINT32] = {0, UINT16_MAX, sizeof(uint16_t), "uint32[]"}, // Upstream qpp/value.c:438 & 445 decode JSON float/double into json_d, but assign json_l (0): case FLOAT: ((float *)data_ptr)[idx] = (float)json_l; /* corrupts 22.5 -> 0.0 */ case DOUBLE: ((double *)data_ptr)[idx] = (double)json_l; /* Gap 2: qpp/iowrite.c:78-90 & qpp/iowrite_text.c:112-124 */ // Blind last-write-wins on .control lets IVI (P10) overwrite ADAS AEB (P60). /* Gap 3: qpp/ioclose.c & qpp/main.c:160 */ // No io_close_ocb holder crash rollback, no CLOCK_MONOTONIC lease TTL, and no ?warden receipt.
Verified references
qpp/README.md:187-199min, max, allowed, arraysize marked Used By QPP? NOqpp/value.c:73VECTOR_UINT32 capped at UINT16_MAX with sizeof(uint16_t)qpp/value.c:434-447FLOAT/DOUBLE default assigns json_l instead of json_dqpp/metadata.c:54-59string-only metadata decoding fails with EINVAL on numeric/array attributesqpp/iowrite.c:78-90 & qpp/iowrite_text.c:112-124blind last-write-wins on .control
Step 2 of 5 · 5 min
Apply patches/qpp-vss-warden.patch with Zero Fuzz (--fuzz=0)
Apply the patch to upstream QPP b5ca892f, including common.mk, meson.build, OCB state, reads, writes, catalog compilation and close recovery. The helper checks git apply --check, applies patch -p1 --fuzz=0, and copies the C core and adapter.
Run
- $
bash scripts/apply-qpp-patch.sh .scratch/qpp-patched - $
npm run build:c
Code & diagnostic output
# From the VssWarden checkout: $ bash scripts/apply-qpp-patch.sh .scratch/qpp-patched # git apply --check + patch -p1 --fuzz=0; 14 original QPP files # Copies vss_warden_core.{c,h} and qpp_warden.{c,h} into qpp/ # Verified with QNX SDP 8.0 (qcc / make / meson) and live QNX 8.0 QEMU target; see README.md.
Verified references
patches/qpp-vss-warden.patch14 upstream QPP files patched with --fuzz=0src/c/vss_warden_core.h & src/c/vss_warden_core.cZero-QNX-header C11 safety engine
Step 3 of 5 · 6 min
Test .control Priority Arbitration & ?warden Diagnostics via echo and cat
On QNX, use shells launched with on -p60 (ADAS) and on -p10 (IVI). Keep the ADAS descriptor open: the actual QNX client priority caps requested priority, and closing the descriptor releases its lease. Run the following ADAS commands in one shell; attempt the IVI write from the other shell within the lease.
Run
- $
exec 3>"/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?control,text,priority=60,lease=60000,as=ADAS_AEB" - $
echo "0" >&3 - $
echo "110" > "/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?control,text,priority=10,lease=1000,as=IVI_EcoMode" - $
cat "/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?warden,text"
Code & diagnostic output
# ADAS shell, launched with on -p60 sh: exec 3>"/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?control,text,priority=60,lease=60000,as=ADAS_AEB" echo "0" >&3 # IVI shell, launched with on -p10 sh: echo "110" > "/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?control,text,priority=10" # Expected: write returns EBUSY while ADAS fd 3 remains open. # ?warden returns a JSON envelope; steps[0].wardenPayload holds the diagnostic.
Verified references
qpp/ioopen.cOP_MODE_WARDEN & ?priority=N,lease=MS,as=ROLE modifier parsingqpp/iowrite.c & qpp/iowrite_text.cqpp_warden_write arbitration hook
Step 4 of 5 · 5 min
Verify Holder Crash (io_close_ocb) & Monotonic Lease Rollback
Close ADAS fd 3 from step 3 to invoke io_close_ocb and restore the safe default. Reads and writes check CLOCK_MONOTONIC expiry; idle expiry is observed on the next I/O. Verified live on QNX Neutrino RTOS 8.0 (QEMU x86_64) and via deterministic host replay.
Run
- $
exec 3>&- - $
cat "/dev/signal/Vehicle/ADAS/CruiseControl/SpeedSet?warden,text" - $
./build/vss-warden-cli --preset preset-3-crash-lease-rollback --seed 20261105
Code & diagnostic output
/* io_close_ocb calls qpp_warden_close(ocb). */ /* The shared C session closes the owner and promotes a live standby or restores default. */ /* qpp_warden_refresh checks CLOCK_MONOTONIC on subsequent reads/writes. */
Verified references
qpp/ioclose.cio_close_ocb calls qpp_warden_closesrc/c/qpp_warden.cCLOCK_MONOTONIC and persistent C session adapter
Step 5 of 5 · 5 min
Run the Shape 1 fast-check Property-Based Verification Suite (P1..P3)
Execute the 3-role Conditional Property-Based Testing (PBT) suite in tests/warden-core-pbt.test.ts using fast-check against the compiled C11 binary and independent TypeScript reference oracle across invariants P1, P2, and P3.
Run
- $
npm test - $
node --experimental-strip-types --test tests/warden-core-pbt.test.ts - $
./build/vss-warden-cli --preset preset-1-bounds-float-bug --seed 20261105
Code & diagnostic output
// Shape 1 Multi-Step State Machine Invariants verified at every step: // P1_VSS_BOUNDS_AND_UPSTREAM_FIX: min/max/allowed/arraysize + FLOAT 22.5 + VECTOR_UINT32 > 65535 // P2_PRIORITY_ARBITRATION_PREEMPTION: higher priority preempts; lower priority rejected with EBUSY // P3_DEAD_OWNER_LEASE_RECOVERY: io_close_ocb / TTL expiry promotes standby or VSS default
Verified references
tests/warden-core-pbt.test.tsRole 1 concrete examples, Role 2 fc.property P1..P3, Role 3 calibrationlib/oracle.tsevaluateVssWardenOracle independent TypeScript state-machine oracle