diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-11 10:38:37 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-11 10:40:03 -0300 |
| commit | 6142fa676731e158622ca7956c150c58bc57f1f2 (patch) | |
| tree | 7413e5740a83c07caa769ee35c57cb770875e0dc /design/motion.md | |
| parent | 6a7a87b8ecb7902de5640cad00028997825024d2 (diff) | |
| download | computeranim-6142fa676731e158622ca7956c150c58bc57f1f2.tar.gz computeranim-6142fa676731e158622ca7956c150c58bc57f1f2.zip | |
design: the graph of a function's blocks; two runs as a pair
From the user. The disassembly's alternate form at a larger scale is the
graph of its basic blocks: a block a box of rows with its offset, lines
and visit count; execution flows down and a back edge is the one thing
that climbs, in its loop's lane with the turn count; what the run never
reached folds away. On the map it takes the disassembly's place; in the
working frame a blocks lens draws its shape and the rows are its view.
Verbs leave and turn carry the mark along an edge.
Two runs of one program share a frame as a pair: the seam is the gutter,
the source shared above, rows only one run has and values that differ
marked at the seam. The scene it is made for sets a plain build against
an ASan one in a stack overflow: the frame beside its shadow bytes, the
store beside its check, and the step where they part.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'design/motion.md')
| -rw-r--r-- | design/motion.md | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/design/motion.md b/design/motion.md index afc3b08..da903ab 100644 --- a/design/motion.md +++ b/design/motion.md @@ -628,6 +628,45 @@ A pointer only read (`cur->next`) brings its arc to full ink with the read old arc fades and nothing replaces it, or a stub to the panel's rule if the target is in the same region but out of the window. +### A block left + +On a function's graph ([`graph`](README.md#graph); mock 24 is reverse's +loop): `jg` decides between the swap and the next pass. + +| Frames | | +| --- | --- | +| 0 to 12 | fire on the `jg` row | +| 18 to 24 | the compare's chips (`zf sf of`), on the `cmp` row above, framed as read: what decides | +| 24 to 42 | the edge it takes draws gold, 3 units, from the port on its target's side to the target's top, `standard` | +| 42 to 66 | the mark travels the edge: the plaque leaves the row, `glide`, 12 f and 2 f a 100 units (30 f at most); the row it left cools to the trail | +| 66 | it lands on the target's first row: the advance | +| 60 to 72, 72 | arm, strike: the target's count, `×5` to `×6` | +| 66 to 84 | the oldest of the three trail edges cools to `dim` | +| 84 to 108 | rest: 1.8 s | + +**A loop's turn** is the same along the back edge: down out of the block, +out to the lane, up the lane (the one thing that climbs), in at the +header's head; the lane's count, `×2` to `×3`, is struck as the mark goes +in. The mark keeps its speed on the climb: a lane of 400 units is 20 f. + +**Rows into blocks** (`spread`, and back, `gather`): a scene that shows +its disassembly as a graph on the map, or a `dive` and a `surface` between +the map's graph and the working frame's rows. What persists slides: every +row travels from its place in the column to its place in its block (36 f, +`glide`, the blocks 4 f apart in layer order), and only then do the +blocks' frames and heads fade in round them (12 f) and the edges draw, +layer by layer (2 f apart, 12 f each). Backwards, the edges and frames go +first and the rows glide home last. No text is ever over text: a row moves +only over page. + +**At a run and a sprint** the graph is at its best: a pass is a path. At a +run the mark goes block to block in 8 f, each edge it takes flashes gold +and cools in 8 f, the counts change in place; nothing is struck. At a +sprint, on the map, the gold moves only when the block changes (4 f at +most), the three trail edges follow it, the loops' lanes count, and the +picture settles at the phrase's end: the counts are where the run left +them, the heat of the path in their numbers. + ### A pointer opened A `loupe`, on a beat the caption names: `rdi` has just taken the next @@ -1086,6 +1125,119 @@ the per-class rows; but its free list is a bitmask in metadata kept apart from the chunks, not links inside them, so its drawing is a row of slots, nearer `array` than `nodes`, with no safe-linking to show. +## A scene: ASan against a plain build + +A [`pair`](README.md#pair): one small program built twice, plain and +with clang's AddressSanitizer (`-O0 -g -fno-omit-frame-pointer -no-pie +-fno-stack-protector`; Arch's clang turns the stack protector on by +default, and with it the plain build dies in `__stack_chk_fail` instead of +at `ret`), each recorded by instruction from `fill`. The program is +[`mock/overflow.c`](mock/overflow.c): `char buf[16]; for (int i = 0; i < +32; i++) buf[i] = 'A';` in a function of its own. Every figure here is +those two recordings' (mocks 26 to 28). + +**The program and its frame.** The tracer's tested `targets/overflow.c` +(a bound `n`, gcc's layout) keeps `i` and `n` above the buffer at -O0: the +loop overwrites them and runs on to the end of the stack, faulting at a +store. This scene's program has a constant bound and is built with clang, +which puts `i` below `buf` (rbp-0x14): the overflow reaches the saved rbp +and the return address and the fault is the classic one, at `ret`. The +target should become [`mock/overflow.c`](mock/overflow.c) with those +flags. The ASan build is shown as a user meets it, with the fake stack +(the default); with `detect_stack_use_after_return=0` the frame would be +on the real stack between the same redzones, a simpler picture and a +second scene. + +**What differs, as recorded.** + +- *The frame.* Plain: `buf` is at rbp-0x10, its last byte against the + saved rbp, the return address the word after. ASan: `buf` is not on + the stack at all but in a fake frame on ASan's fake stack (7bfff58f0000, + 64 bytes): a header (magic `41b58ab3`, a descriptor `"1 32 16 5 buf:3"`, + the pc, the real stack), `buf` at +0x20, a redzone at +0x30; the real + stack holds only spills, the saved rbp and the return address, far away. + The two stack panels are scrolled so that `buf` faces `buf`: then plain's + saved rbp faces ASan's redzone, and its return address the redzone's + second word. That facing is the scene. +- *The code.* Line 4's store is one instruction plain + (`mov [rbp + rax - 0x10]▮, 0x41`), eight a turn; ASan's turn is + seventeen: the address, `shr rax, 3`, the shadow's load at `rax + + 7fff8000`, `cmp al, 0`, `je` to the store; the partial check (`and rax, + 7`, `cmp al, cl`, `jl`) and `call __asan_report_store1` only when the + shadow is not 0. The prologue (38 instructions and + `__asan_stack_malloc_0`, 250) writes the header and poisons the shadow, + `f1 f1 f1 f1 f8 f8 f3 f3`; line 3, which plain has no instruction for, + turns `f8 f8` to `00 00` (buf's scope begins). +- *The shadow.* One byte for each word of the fake frame, on the word's own + row of the stack panel ([`slot`](README.md#slot)): `f1` four times (the + header), `00 00` (buf), `f3 f3` (the redzone). +- *When they part.* At i = 16: plain's store writes `41` into the saved + rbp's low byte (7fffffffed00 becomes 7fffffffed41); ASan's check loads + `f3`, `je` is not taken, the partial check (`0 : f3`, signed 0 against + -13) is not taken, and it calls `__asan_report_store1(7bfff58f0030)`; + the store never runs. After that plain goes on alone: by i = 23 the saved + rbp is `4141414141414141`, at i = 24 the return address briefly points + at `fill+1`, by i = 31 it is `4141414141414141`; `pop rbp`, then `ret` + faults on a non-canonical address: SIGSEGV, rip still at `ret`, exit + 139. ASan's report: `stack-buffer-overflow on address 0x7bfff58f0030 ... + WRITE of size 1 ... [32, 48) 'buf' (line 3) <== Memory access at offset + 48 overflows this variable`. +- *How long.* Plain: 263 instructions from `fill` to the fault. ASan: 578 + to the report's call, then about 4.75 million to write the report and + exit. + +**The beats**, with the captions on the rules (frames from the scene's +first; a caption lands, leads its step by at least 60 f, 120 for the +first, and leaves only in a rest; every one up its reading time and at +most 642 f). Each step is a source line in both builds, or one turn of the +loop; inside it each side walks its own rows (README, `pair`). + +| Lands | Leaves | Caption | The step, firing at | What plays | +| --- | --- | --- | --- | --- | +| 78 | 452 | Plain against AddressSanitizer: one loop writes 32 bytes into a 16-byte buffer. | `fill()` called in both, 198 | the call, as any; `establish` before it | +| 470 | 884 | ASan's prologue moves buf to a fake frame and poisons its shadow: f1 before buf, f3 after. | line 2, the prologues, 530 | plain: two rows walked. ASan: its 38 rows at a run inside the step, `__asan_stack_malloc_0` stepped over; the fake frame's rows come in (12 f), the header's words struck; the shadow's cells struck 2 f apart, `f1 f1 f1 f1 f8 f8 f3 f3` | +| 902 | 1255 | Line 3 is ASan's alone: buf's scope begins, its shadow f8 f8 turns 00 00. | line 3, 962 | ASan's one row, `only here`; plain holds; the two cells struck | +| 1273 | 1651 | Before each store ASan reads buf[i]'s byte of shadow, at (addr >> 3) + 7fff8000. | i = 0, the check, 1333 | ASan's address and check rows walked, 36 f a row, the shadow cell framed as read when its load runs; plain's plaque waits on the row facing them | +| 1669 | 2076 | It is 00: the store may go. Both write 'A'; plain in one instruction, ASan in seventeen. | i = 0, the stores, 1729 | both stores strike together (6 f apart, plain first), each side's `i++` | +| 2094 | 2736 | Fourteen more turns, at a run: buf fills on both sides. | i = 1 to 14, a run, 2154 | a run: no strikes, no corners; buf's bytes change in place; settled at the end | +| 2754 | 3118 | i = 15, the last byte of buf. Still 00 on ASan's side; still buf on plain's. | i = 15, walked, 2814 | both walked; the last 00 read | +| 3136 | 3528 | i = 16, one past buf. Plain writes 'A' into the saved rbp; ASan reads f3, a redzone. | i = 16, they part, 3196 | the chart below | +| 3546 | 3967 | ASan's branch to the store is not taken: it calls the report, which names buf and the write. | the report, 3606 | ASan's partial check and its call walked; its run stops: its registers give way to its stderr, the report's lines, the three the caption names framed | +| 3985 | 4495 | Plain goes on alone: the saved rbp, then the return address, become AAAAAAAA. | i = 17 to 31, a run, 4045 | plain alone at a run; ASan's side holds its last picture; at the run's end the saved rbp and return address settled at `4141414141414141`, `differs` on their rows | +| 4513 | 4903 | The loop ends; pop rbp, then ret to 4141414141414141: the CPU faults. SIGSEGV. | the loop's exit, `pop`, `ret`, 4573 | walked: rbp struck; `ret` faults: the `fault` mark on its row, hazard bands round an ink plaque, `SIGSEGV`; rip stays | + +The cut at 5023, 83.7 s, after 2 s on the two last pictures: a fault on +the left, a report on the right. + +**The step in which they part** (i = 16), from its fire: + +| Frames | | +| --- | --- | +| 0 to 12 | fire on line 4, both sides' plaques on the turn's first row | +| 18 to 66 | plain walks to its store, its rows spread over the time ASan takes to reach its check: ASan's address rows, 12 f each | +| 72 to 78 | the two first different rows framed `attention`, one each side: plain's store, ASan's shadow load | +| 84 to 96, 96 | plain: arm, strike the saved rbp's low byte, `00` to `41`; the row's value turns to 7fffffffed41 (`extend`) and its `differs` bar comes in (12 f) | +| 102 to 108 | ASan: the shadow load's cell, `f3`, framed as read, and the load's annotation reads it | +| 114 to 126 | ASan: `cmp al, 0`, its values `f3 : 0` and `zf` | +| 132 to 150 | ASan: `je` not taken, its row's annotation `not taken`; plain's plaque goes on to `i++` | +| 186 to 222 | hold | +| 222 to 234 | advance | +| 234 to 258 | rest: 4.3 s | + +**What the recordings must hold, each run, per stop** (beyond what any +scene asks): the shadow bytes for the stack window and for every fake +frame the window shows, each with the 8 application bytes it stands for; +which words are a fake frame (ASan's fake stack mapping, the frame's base +and size class) and its header decoded (magic, the descriptor's variables +with their offsets, sizes and lines, the pc); the red zone under rsp (the +plain build's `buf` and `i` live there); names for ASan's runtime +(`__asan_report_store1`, `__asan_stack_malloc_0`); the run's stderr as +written, by stop (the report's lines arrive by `write(2, …)`, 18 of them, +1.5 M to 4.7 M instructions after the call: a `continue` to the exit); a +fault: the signal, rip and rsp at it, the exit status. And for the pair: +the two recordings' stops matched by source line and by the loop's turn (i +from its slot), so a step can be one line or one turn in both. + ## Stills Seen while looking at motion; against `README.md`. |
