mirror of
https://github.com/brazilofmux/tinymux
synced 2026-08-13 00:23:11 -04:00
color_ops.c is compiled twice -- once into libmux for the host, once into the freestanding rv64 blob -- and the blob is then executed by two engines of our own. That is four implementations of one source, and until now the only differential we had compared the first against itself. #2002 is where that bit. A cursor rewrite of the word-list functions was verified on the host across 560,000 cases with a negative control, and it still broke in the blob; the attempt was reverted with no root cause, because reproducing it needed the blob under an external oracle and no box had run one. This adds that. One freestanding guest binary uses only Linux syscalls 64 and 93 -- exactly what dbt_test.cpp's ELF harness implements -- so qemu-riscv64-static, rv64_interp_run and the DBT all execute the SAME instruction stream rather than three builds of one source. The host leg links the already-built libmux, which makes it the pre-change implementation and therefore the specification, not a hand-written table of expectations. The battery is 16 fixed cases, 5 at the max_words cap, and 200 seeded random cases driven by the same LCG on every route, so inputs are identical by construction. 1,221 transcript lines. The cap cases earn their place: a cap-check off-by-one moves 4 lines and the random leg catches it never, while a common-path off-by-one moves 212. Both controls were run. What it found on first use is #2019 -- the DBT returns a wrong answer for correct RV64 code when block chaining is enabled, intermittently. So the #2002 rewrite was sound and the divergence was ours. repro/ carries that reproducer: the rewrite as a patch (color_ops.c is generated -- a real change belongs in color_ops.rl) and a script that loops it and reports a rate, because a single run passes about half the time. test-codiff joins TEST_TARGETS and passes on master. test-codiff-2019 is deliberately NOT in `make test`: it is expected to fail. Both skip loudly without a RISC-V cross-compiler rather than reporting a pass for a run that compiled nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
30 lines
848 B
C
30 lines
848 B
C
/* host_main.c -- host side of the color_ops three-way differential.
|
|
*
|
|
* Runs the identical case battery against the co_* functions as compiled
|
|
* for the host (libmux), producing a transcript in the same format as the
|
|
* guest. This is the fourth route, and the one Macbook's host differential
|
|
* already covered -- it is here so that "host vs guest" is a diff of two
|
|
* files rather than an argument.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <color_ops.h>
|
|
|
|
static void o_str(const char *s) { fputs(s, stdout); }
|
|
static void o_uint(unsigned long long v) { printf("%llu", v); }
|
|
static void o_bytes(const unsigned char *p, unsigned long n)
|
|
{
|
|
unsigned long i;
|
|
for (i = 0; i < n; i++) printf("%02x", p[i]);
|
|
}
|
|
|
|
#include "cases.h"
|
|
|
|
int main(void)
|
|
{
|
|
run_all(FUZZ_ITERS);
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|