|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Seeded, oracle-checked fuzz of the ProcessMemory circular-queue arithmetic. More...
#include "ProcessMemory.h"#include "MemoryManager.h"#include "UnitTestFramework.h"#include <deque>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Classes | |
| struct | cmlabs::RingRand |
| Deterministic xorshift64* — same sequence on every platform, unlike rand(). More... | |
| struct | cmlabs::RingRef |
| One entry of the reference model: what a correct queue MUST hand back, in order. More... | |
Namespaces | |
| namespace | cmlabs |
Functions | |
| static uint32 | cmlabs::RingChecksum (const char *p, uint32 len) |
| FNV-1a over the payload body. | |
| static void | cmlabs::RingFillPayload (char *buf, uint32 len, uint32 serial) |
| Deterministic payload: content is a pure function of (serial, len), so a reader can re-derive what it SHOULD have received and prove corruption rather than infer it. | |
| static uint32 | cmlabs::RingEnvU32 (const char *name, uint32 def) |
| Env integer with default. | |
| static const char * | cmlabs::RingClass (const RingRef &want, DataMessage *got, uint32 &gotSerial, uint32 &gotLen, uint32 &gotSum) |
| Classifier for a single divergence between the queue and the reference model. | |
| static DataMessage * | cmlabs::RingMakeMsg (uint32 serial, uint32 len, RingRef &ref) |
| Build one message carrying serial serial and a deterministic payload of len bytes, and fill ref with what a correct queue must return for it. | |
| static const char * | cmlabs::RingCheckInvariants (MessageQueueHeader *q, uint32 expectCount, char *detail, uint32 detailSize) |
| Walk the live region of a queue and assert its bookkeeping is self-consistent. | |
| static bool | cmlabs::RingRunSeed (MemoryManager *manager, uint64 seed, uint32 iters, bool selftest, bool checkInvariants, bool invariantSelftest) |
| Run one seed to completion. | |
Seeded, oracle-checked fuzz of the ProcessMemory circular-queue arithmetic.
Phase 1: SINGLE PROCESS, single writer/reader interleaved on one queue (MSGQ of process 0). No concurrency, on purpose: the ring arithmetic in addToQ/waitForQ/ resizeQ is pure integer bookkeeping, and removing concurrency is what makes a failing seed replay byte-for-byte.
Every message carries its own serial + a checksum over a variable-length payload, and every read is compared against a std::deque reference model, so a divergence is classified (LOST / DUPLICATED / REORDERED / CORRUPT / SHORT) rather than merely noticed.
Targets the states the existing ProcessMemory::UnitTest cannot reach:
Env: PSY_RING_SEED=<n> replay one exact seed PSY_RING_ITERS=<n> ops per seed (default 20000) PSY_RING_SEEDS=<n> number of seeds (default 8) PSY_RING_SELFTEST=1 positive control: injects a divergence; MUST fail
Definition in file ProcessMemoryFuzz.cpp.