From 576a78b4de02c4c6566c327d85c465554d293975 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 12:49:15 -0300 Subject: design: the overflow as bytes; a minimap in each pane From the user. In the pair a frame is a dump of eight bytes a row read by its own fields, so each turn of the loop is one more letter and the letters are seen to cross from buf into the saved rbp and the return address, which reads as code until they reach it. Each pane with more than it shows carries its own minimap, a strip of its column of the map at four units a row with the pane's window outlined and what happens off the window marked there; the corner minimap is gone, and in the dive each column of the map folds into its pane's strip. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- design/mock/09-context-480.png | Bin 36033 -> 36283 bytes design/mock/09-context.png | Bin 232320 -> 224163 bytes design/mock/09-context.svg | 2600 ++++++++++++++------------------- design/mock/10-context-step-480.png | Bin 36917 -> 37286 bytes design/mock/10-context-step.png | Bin 236387 -> 228491 bytes design/mock/10-context-step.svg | 2608 ++++++++++++++------------------- design/mock/11-context-lens-480.png | Bin 36603 -> 37128 bytes design/mock/11-context-lens.png | Bin 225200 -> 217422 bytes design/mock/11-context-lens.svg | 2485 ++++++++++++------------------- design/mock/20-dive.png | Bin 1321188 -> 1665696 bytes design/mock/21-loupe-480.png | Bin 38102 -> 38344 bytes design/mock/21-loupe.png | Bin 243789 -> 235323 bytes design/mock/21-loupe.svg | 2753 ++++++++++++++--------------------- design/mock/26-pair-rest-480.png | Bin 30674 -> 33643 bytes design/mock/26-pair-rest.png | Bin 208546 -> 215411 bytes design/mock/26-pair-rest.svg | 447 ++++-- design/mock/27-pair-store-480.png | Bin 21819 -> 25106 bytes design/mock/27-pair-store.png | Bin 154167 -> 171996 bytes design/mock/27-pair-store.svg | 67 + design/mock/28-pair-part-480.png | Bin 32174 -> 34966 bytes design/mock/28-pair-part.png | Bin 214064 -> 220279 bytes design/mock/28-pair-part.svg | 451 ++++-- design/mock/38-pair-ret-480.png | Bin 0 -> 36174 bytes design/mock/38-pair-ret.png | Bin 0 -> 219525 bytes design/mock/38-pair-ret.svg | 509 +++++++ design/mock/39-minimap-1to1.png | Bin 0 -> 53199 bytes design/mock/context.py | 7 +- design/mock/map.py | 184 ++- design/mock/pair.py | 311 +++- 29 files changed, 5762 insertions(+), 6660 deletions(-) create mode 100644 design/mock/38-pair-ret-480.png create mode 100644 design/mock/38-pair-ret.png create mode 100644 design/mock/38-pair-ret.svg create mode 100644 design/mock/39-minimap-1to1.png (limited to 'design/mock') diff --git a/design/mock/09-context-480.png b/design/mock/09-context-480.png index 52edc14..f047b56 100644 Binary files a/design/mock/09-context-480.png and b/design/mock/09-context-480.png differ diff --git a/design/mock/09-context.png b/design/mock/09-context.png index b262b5b..d00d8f2 100644 Binary files a/design/mock/09-context.png and b/design/mock/09-context.png differ diff --git a/design/mock/09-context.svg b/design/mock/09-context.svg index c867889..5fc1364 100644 --- a/design/mock/09-context.svg +++ b/design/mock/09-context.svg @@ -20,7 +20,7 @@ head ) { - + 21 struct @@ -95,7 +95,7 @@ 23 mov rax, rdi - + 10019 @@ -103,13 +103,13 @@ 21 mov rdi, [rdi + 8] -1004098 - - -1004070 - - -9 +1004098 + + +1004070 + + +9 10019 2a 22 @@ -139,11 +139,11 @@ 10019 37 ret - + 10019 38 endbr64 -_init +_init @@ -266,7 +266,7 @@ rbp rsp +0 -saved rbp +saved rbp 7fffffffe ce0 @@ -291,14 +291,14 @@ 7ffff7e20de8 +18 -saved rbx +saved rbx 7fffffffe cf8 0 +20 -saved rbp +saved rbp 7fffffffe d00 @@ -331,21 +331,20 @@ 7fffffffee38 -7fffffffefea - - -".… - - - -reverse - - - -main - - -libc+27781 + + + + + + +reverse + + + +main + + +libc+27781 @@ -533,1501 +532,1058 @@ 36 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -moment 2 of 4 +moment 2 of 4 Stopped in reverse, about to load head->next. rdi points at a node; the word after its value is the next node. diff --git a/design/mock/10-context-step-480.png b/design/mock/10-context-step-480.png index 2a9eaad..87a7f5e 100644 Binary files a/design/mock/10-context-step-480.png and b/design/mock/10-context-step-480.png differ diff --git a/design/mock/10-context-step.png b/design/mock/10-context-step.png index 7290e91..51910b8 100644 Binary files a/design/mock/10-context-step.png and b/design/mock/10-context-step.png differ diff --git a/design/mock/10-context-step.svg b/design/mock/10-context-step.svg index c788864..c693bf6 100644 --- a/design/mock/10-context-step.svg +++ b/design/mock/10-context-step.svg @@ -20,7 +20,7 @@ head ) { - + 21 struct @@ -95,7 +95,7 @@ 23 mov rax, rdi - + 10019 @@ -103,14 +103,14 @@ 21 mov rdi, [rdi + 8] - -1004098 - - -1004070 - - -9 + +1004098 + + +1004070 + + +9 10019 2a 22 @@ -140,11 +140,11 @@ 10019 37 ret - + 10019 38 endbr64 -_init +_init @@ -267,7 +267,7 @@ rbp rsp +0 -saved rbp +saved rbp 7fffffffe ce0 @@ -292,14 +292,14 @@ 7ffff7e20de8 +18 -saved rbx +saved rbx 7fffffffe cf8 0 +20 -saved rbp +saved rbp 7fffffffe d00 @@ -332,21 +332,20 @@ 7fffffffee38 -7fffffffefea - - -".… - - - -reverse - - - -main - - -libc+27781 + + + + + + +reverse + + + +main + + +libc+27781 @@ -545,1505 +544,1060 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -moment 3 of 4 +moment 3 of 4 The load read the word at 1004098: the address of the next node. rdi holds it now, and points at the node whose value is 9. diff --git a/design/mock/11-context-lens-480.png b/design/mock/11-context-lens-480.png index 6285b81..1cf154e 100644 Binary files a/design/mock/11-context-lens-480.png and b/design/mock/11-context-lens-480.png differ diff --git a/design/mock/11-context-lens.png b/design/mock/11-context-lens.png index 6e17b47..f6051fb 100644 Binary files a/design/mock/11-context-lens.png and b/design/mock/11-context-lens.png differ diff --git a/design/mock/11-context-lens.svg b/design/mock/11-context-lens.svg index b8188b3..74f3763 100644 --- a/design/mock/11-context-lens.svg +++ b/design/mock/11-context-lens.svg @@ -20,8 +20,8 @@ reverse ( struct -node -… +n +… 19 struct node @@ -36,7 +36,7 @@ head ) { - + 21 struct @@ -97,7 +97,7 @@ 23 mov rax, rdi - + 10019 @@ -105,14 +105,14 @@ 21 mov rdi, [rdi + 8] - -1004098 - - -1004070 - - -9 + +1004098 + + +1004070 + + +9 10019 2a 22 @@ -253,7 +253,7 @@ rbp rsp +0 -saved rbp +saved rbp 7fffffffe ce0 @@ -278,14 +278,14 @@ 7ffff7e20de8 +18 -saved rbx +saved rbx 7fffffffe cf8 0 +20 -saved rbp +saved rbp 7fffffffe d00 @@ -303,14 +303,14 @@ 7ffff7c27781 libc+27781 - - - -reverse - - - -main + + + +reverse + + + +main @@ -560,1505 +560,950 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -moment 3 of 4 +moment 3 of 4 The load read the word at 1004098: the address of the next node. rdi holds it now, and points at the node whose value is 9. diff --git a/design/mock/20-dive.png b/design/mock/20-dive.png index 5efba9c..3d2925f 100644 Binary files a/design/mock/20-dive.png and b/design/mock/20-dive.png differ diff --git a/design/mock/21-loupe-480.png b/design/mock/21-loupe-480.png index 383c7f2..76852b2 100644 Binary files a/design/mock/21-loupe-480.png and b/design/mock/21-loupe-480.png differ diff --git a/design/mock/21-loupe.png b/design/mock/21-loupe.png index ed97f20..a3ed604 100644 Binary files a/design/mock/21-loupe.png and b/design/mock/21-loupe.png differ diff --git a/design/mock/21-loupe.svg b/design/mock/21-loupe.svg index 5a3e837..a04e65b 100644 --- a/design/mock/21-loupe.svg +++ b/design/mock/21-loupe.svg @@ -20,7 +20,7 @@ head ) { - + 21 struct @@ -95,7 +95,7 @@ 23 mov rax, rdi - + 10019 @@ -103,14 +103,14 @@ 21 mov rdi, [rdi + 8] - -1004098 - - -1004070 - - -9 + +1004098 + + +1004070 + + +9 10019 2a 22 @@ -140,11 +140,11 @@ 10019 37 ret - + 10019 38 endbr64 -_init +_init @@ -267,7 +267,7 @@ rbp rsp +0 -saved rbp +saved rbp 7fffffffe ce0 @@ -292,14 +292,14 @@ 7ffff7e20de8 +18 -saved rbx +saved rbx 7fffffffe cf8 0 +20 -saved rbp +saved rbp 7fffffffe d00 @@ -332,21 +332,20 @@ 7fffffffee38 -7fffffffefea - - -".… - - - -reverse - - - -main - - -libc+27781 + + + + + + +reverse + + + +main + + +libc+27781 @@ -676,1648 +675,1060 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -moment 3 of 4 +moment 3 of 4 rdi holds 1004070; under it opens the heap round that node. -The minimap shows the same loupe at its place on the map. +Each pane's minimap shows where its rows are in the whole. diff --git a/design/mock/26-pair-rest-480.png b/design/mock/26-pair-rest-480.png index be057a5..6e2c5a1 100644 Binary files a/design/mock/26-pair-rest-480.png and b/design/mock/26-pair-rest-480.png differ diff --git a/design/mock/26-pair-rest.png b/design/mock/26-pair-rest.png index d5eca7f..a609773 100644 Binary files a/design/mock/26-pair-rest.png and b/design/mock/26-pair-rest.png differ diff --git a/design/mock/26-pair-rest.svg b/design/mock/26-pair-rest.svg index c6bbd84..45d73ac 100644 --- a/design/mock/26-pair-rest.svg +++ b/design/mock/26-pair-rest.svg @@ -154,75 +154,133 @@ plain · stack -red zone, buf, the frame · rsp at +0 · the frames they belong to --30 -7fffffffec -b0 - - -0 --28 -7fffffffec -b8 - - -0 --20 -7fffffffec -c0 - - -0 --18 -i, high half -7fffffffec -c8 - - -0xf00000000 --10 -buf[0..7] -7fffffffec -d0 - - -"AAAAAAAA" --8 -buf[8..15] -7fffffffec -d8 - - -"AAAAAAA" -rbp rsp - -+0 -saved rbp -7fffffffec -e0 - - -7fffffffed00 -+8 -return -7fffffffec -e8 - - -401134 -main+20 -+10 -7fffffffec -f0 - - -0 -+18 -7fffffffec -f8 - - -0 +fill's frame as bytes, eight a row +7fffffffec +b0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +b8 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c8 + + +0f +00 +00 +00 +i +15 +00 +00 +00 +00 +7fffffffec +d0 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +7fffffffec +d8 + +41 +41 +41 +41 +41 +41 + +41 +00 +buf[8..15] +"AAAAAAA" +rbp rsp + +7fffffffec +e0 + +00 +ed +ff +ff +ff +7f +00 +00 +saved rbp + + +7fffffffed00 + +7fffffffec +e8 + +34 +11 +40 +00 +00 +00 +00 +00 +return + + +401134 +main+20 + +7fffffffec +f0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +f8 +00 +00 +00 +00 +00 +00 +00 +00 @@ -317,101 +375,172 @@ -asan · fake stack -the fake frame, its shadow · the real stack's way back · the frames they belong to -magic -7 -bfff58f0000 - - -0x41b58ab3 -descr -7 -bfff58f0008 - - -5387a7 - - -"1 32 16 5 buf:3" -pc -7 -bfff58f0010 - - -523c60 -fill -real stack -7 -bfff58f0018 - - -7fffffffec10 -buf[0..7] -7 -bfff58f0020 - - -"AAAAAAAA" -buf[8..15] -7 -bfff58f0028 - - -"AAAAAAA" -redzone -7 -bfff58f0030 - - -0 -redzone -7 -bfff58f0038 - - -7bfff58e8000 -rbp - -saved rbp -7 -fffffffecc0 - - -7fffffffece0 -return -7 -fffffffecc8 - - -523c54 -main+20 +asan · fake frame +its shadow at addr >> 3 + 7fff8000 · then the real stack's way back + +f1 +7bfff58f00 +00 + +b3 +8a +b5 +41 +00 +00 +00 +00 +magic + +f1 +7bfff58f00 +08 + +a7 +87 +53 +00 +00 +00 +00 +00 +descr + + +5387a7 +"1 32 16 5 b… + +f1 +7bfff58f00 +10 + +60 +3c +52 +00 +00 +00 +00 +00 +pc + + +523c60 +fill + +f1 +7bfff58f00 +18 + +10 +ec +ff +ff +ff +7f +00 +00 +real stack + + +7fffffffec10 +00 +7bfff58f00 +20 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +00 +7bfff58f00 +28 + +41 +41 +41 +41 +41 +41 +41 +00 +buf[8..15] +"AAAAAAA" + +f3 +7bfff58f00 +30 + +00 +00 +00 +00 +00 +00 +00 +00 +redzone + + +f3 +7bfff58f00 +38 + +00 +80 +8e +f5 +ff +7b +00 +00 +redzone + + +rbp + +7fffffffecc0 + +e0 +ec +ff +ff +ff +7f +00 +00 +saved rbp + + +7fffffffece0 +7fffffffecc8 + +54 +3c +52 +00 +00 +00 +00 +00 +return + + +523c54 +main+20 fill - -f1 - -f1 - -f1 - -f1 -00 -00 - -f3 - -f3 - - - - - i 15 · moments 156 / 753 -The same line, two builds: plain stores the byte; ASan first -reads the byte of shadow that stands for it: 00, so it may. +Each turn is one more byte: 41, the letter A. Fifteen in buf, +on both sides; ASan read 00 in the shadow before each one. diff --git a/design/mock/27-pair-store-480.png b/design/mock/27-pair-store-480.png index 6fb2409..ee4e250 100644 Binary files a/design/mock/27-pair-store-480.png and b/design/mock/27-pair-store-480.png differ diff --git a/design/mock/27-pair-store.png b/design/mock/27-pair-store.png index 2563ead..13071cb 100644 Binary files a/design/mock/27-pair-store.png and b/design/mock/27-pair-store.png differ diff --git a/design/mock/27-pair-store.svg b/design/mock/27-pair-store.svg index 637f851..2161574 100644 --- a/design/mock/27-pair-store.svg +++ b/design/mock/27-pair-store.svg @@ -213,6 +213,73 @@ jmp 40114b the check: plain has nothing here + + + +plain · buf +the turn's byte +7fffffffec +d0 + +41 +41 +41 + +41 +00 +00 +00 +00 +buf[0..7] +"AAAA" +7fffffffec +d8 + +00 +00 +00 +00 +00 +00 +00 +00 +buf[8..15] +"" + + + +asan · buf +its shadow, read before the store +00 + +7bfff58f00 +20 + +41 +41 +41 + +41 +00 +00 +00 +00 +buf[0..7] +"AAAA" +00 +7bfff58f00 +28 + +00 +00 +00 +00 +00 +00 +00 +00 +buf[8..15] +"" Plain: one store. ASan: the address, its shadow byte (addr >> 3 + 7fff8000), a compare with 0, a branch; the partial check and the report only if it is not 0. diff --git a/design/mock/28-pair-part-480.png b/design/mock/28-pair-part-480.png index adaeb20..c910052 100644 Binary files a/design/mock/28-pair-part-480.png and b/design/mock/28-pair-part-480.png differ diff --git a/design/mock/28-pair-part.png b/design/mock/28-pair-part.png index 8651eb6..cd2cc37 100644 Binary files a/design/mock/28-pair-part.png and b/design/mock/28-pair-part.png differ diff --git a/design/mock/28-pair-part.svg b/design/mock/28-pair-part.svg index e5cd106..04bc5e7 100644 --- a/design/mock/28-pair-part.svg +++ b/design/mock/28-pair-part.svg @@ -155,76 +155,134 @@ plain · stack -red zone, buf, the frame · rsp at +0 · the frames they belong to --30 -7fffffffec -b0 - - -0 --28 -7fffffffec -b8 - - -0 --20 -7fffffffec -c0 - - -0 --18 -i, high half -7fffffffec -c8 - - -0x1000000000 --10 -buf[0..7] -7fffffffec -d0 - - -"AAAAAAAA" --8 -buf[8..15] -7fffffffec -d8 - - -"AAAAAAAA" -rbp rsp - -+0 -saved rbp -7fffffffec -e0 - - - -7fffffffed41 -+8 -return -7fffffffec -e8 - - -401134 -main+20 -+10 -7fffffffec -f0 - - -0 -+18 -7fffffffec -f8 - - -0 +fill's frame as bytes, eight a row +7fffffffec +b0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +b8 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c8 + + +10 +00 +00 +00 +i +16 +00 +00 +00 +00 +7fffffffec +d0 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +7fffffffec +d8 + +41 +41 +41 +41 +41 +41 +41 + +41 +buf[8..15] +"AAAAAAAA" +rbp rsp + +7fffffffec +e0 + + +41 +ed +ff +ff +ff +7f +00 +00 +saved rbp + + +7fffffffed41 + +7fffffffec +e8 + +34 +11 +40 +00 +00 +00 +00 +00 +return + + +401134 +main+20 + +7fffffffec +f0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +f8 +00 +00 +00 +00 +00 +00 +00 +00 @@ -327,102 +385,173 @@ -asan · fake stack -the fake frame, its shadow · the real stack's way back · the frames they belong to -magic -7 -bfff58f0000 - - -0x41b58ab3 -descr -7 -bfff58f0008 - - -5387a7 - - -"1 32 16 5 buf:3" -pc -7 -bfff58f0010 - - -523c60 -fill -real stack -7 -bfff58f0018 - - -7fffffffec10 -buf[0..7] -7 -bfff58f0020 - - -"AAAAAAAA" -buf[8..15] -7 -bfff58f0028 - - -"AAAAAAAA" -redzone -7 -bfff58f0030 - - -0 -redzone -7 -bfff58f0038 - - -7bfff58e8000 -rbp - -saved rbp -7 -fffffffecc0 - - -7fffffffece0 -return -7 -fffffffecc8 - - -523c54 -main+20 +asan · fake frame +its shadow at addr >> 3 + 7fff8000 · then the real stack's way back + +f1 +7bfff58f00 +00 + +b3 +8a +b5 +41 +00 +00 +00 +00 +magic + +f1 +7bfff58f00 +08 + +a7 +87 +53 +00 +00 +00 +00 +00 +descr + + +5387a7 +"1 32 16 5 b… + +f1 +7bfff58f00 +10 + +60 +3c +52 +00 +00 +00 +00 +00 +pc + + +523c60 +fill + +f1 +7bfff58f00 +18 + +10 +ec +ff +ff +ff +7f +00 +00 +real stack + + +7fffffffec10 +00 +7bfff58f00 +20 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +00 +7bfff58f00 +28 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[8..15] +"AAAAAAAA" + +f3 + +7bfff58f00 +30 + +00 +00 +00 +00 +00 +00 +00 +00 +redzone + + +f3 +7bfff58f00 +38 + +00 +80 +8e +f5 +ff +7b +00 +00 +redzone + + +rbp + +7fffffffecc0 + +e0 +ec +ff +ff +ff +7f +00 +00 +saved rbp + + +7fffffffece0 +7fffffffecc8 + +54 +3c +52 +00 +00 +00 +00 +00 +return + + +523c54 +main+20 fill - -f1 - -f1 - -f1 - -f1 -00 -00 - -f3 - - -f3 - - - - - i 16 · moments 164 / 770 -i = 16, one past buf: plain writes 'A' into the saved rbp. ASan reads -the shadow first: f3, a redzone. Its branch to the store is not taken. +i = 16, one past buf: plain writes 41, an 'A', into the saved rbp. +ASan reads the shadow first: f3, a redzone. It does not store. diff --git a/design/mock/38-pair-ret-480.png b/design/mock/38-pair-ret-480.png new file mode 100644 index 0000000..85f2b62 Binary files /dev/null and b/design/mock/38-pair-ret-480.png differ diff --git a/design/mock/38-pair-ret.png b/design/mock/38-pair-ret.png new file mode 100644 index 0000000..efd37c0 Binary files /dev/null and b/design/mock/38-pair-ret.png differ diff --git a/design/mock/38-pair-ret.svg b/design/mock/38-pair-ret.svg new file mode 100644 index 0000000..aec2130 --- /dev/null +++ b/design/mock/38-pair-ret.svg @@ -0,0 +1,509 @@ + + + + + + +overflow.c · both builds +lines 2 to 6 of 10 +2 +__attribute__ +( +( +noinline +) +) +static +void +fill +( +void +) +{ +3 +char +buf +[ +16 +] +; + + +4 +for +( +int +i += +0 +; +i +< +32 +; +i ++ ++ +) +buf +[ +i +] += +' +A +' +; +5 +} +6 + + +asan + + + + +disassembly +plain · fill +4011 +44 +4 +mov +[rbp - 0x14] + + + + +, 0 + +4011 +4b +cmp +[rbp - 0x14] + + + + +, 0x20 + +4011 +4f +jge +401165 + +4011 +51 +movsxd +rax, [rbp - 0x14] + + + + + + + + +4011 +55 +mov +[rbp + rax - 0x10] + +, 0x41 +7fffffffeceb + + +0x41 +65 +4011 +5a +mov +eax, [rbp - 0x14] +4011 +5d +add +eax, 1 +4011 +60 +mov +[rbp - 0x14], eax +4011 +63 +jmp +40114b + + + +plain · registers +the line's registers, and rip +rax +0x1b +27 +rbp +7fffffffece0 + + +0x4141414141414141 +rsp +7fffffffece0 + + +rip +401155 +fill+21 + + + +plain · stack +fill's frame as bytes, eight a row +7fffffffec +b0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +b8 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +c8 + + +1b +00 +00 +00 +i +27 +00 +00 +00 +00 +7fffffffec +d0 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +7fffffffec +d8 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[8..15] +"AAAAAAAA" +rbp rsp + +7fffffffec +e0 + +41 +41 +41 +41 +41 +41 +41 +41 +saved rbp +0x4141414141414141 + +7fffffffec +e8 + + +41 + +41 + +41 + +41 +00 +00 +00 +00 +return +0x41414141 + +7fffffffec +f0 +00 +00 +00 +00 +00 +00 +00 +00 +7fffffffec +f8 +00 +00 +00 +00 +00 +00 +00 +00 + + + +fill + + + +disassembly +asan · fill · stopped +523d +4b +4 +and +rax, 7 +523d +4f +cmp +al, cl + +523d +51 +jl +523d5b + +523d +53 +mov +rdi, [rbx] + +523d +56 +call +4e8450 +__asan_report_store1 +never returned + + + + + + + + +asan · stderr +its report, as written · exit 1 +==1438870==ERROR: AddressSanitizer: stack-buffer-overflow on address 0… + +WRITE of size 1 at 0x7bfff58f0030 thread T0 + +Address 0x7bfff58f0030 is located in stack of thread T0 at offset 48 i… + This frame has 1 object(s): + [32, 48) 'buf' (line 3) <== Memory access at offset 48 overflows t… + +=>0x7bfff58f0000: f1 f1 f1 f1 00 00[f3]f3 00 00 00 00 00 00 00 00 + + + + +asan · fake frame +its shadow at addr >> 3 + 7fff8000 · then the real stack's way back + +f1 +7bfff58f00 +00 + +b3 +8a +b5 +41 +00 +00 +00 +00 +magic + +f1 +7bfff58f00 +08 + +a7 +87 +53 +00 +00 +00 +00 +00 +descr + + +5387a7 +"1 32 16 5 b… + +f1 +7bfff58f00 +10 + +60 +3c +52 +00 +00 +00 +00 +00 +pc + + +523c60 +fill + +f1 +7bfff58f00 +18 + +10 +ec +ff +ff +ff +7f +00 +00 +real stack + + +7fffffffec10 +00 +7bfff58f00 +20 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[0..7] +"AAAAAAAA" +00 +7bfff58f00 +28 + +41 +41 +41 +41 +41 +41 +41 +41 +buf[8..15] +"AAAAAAAA" + +f3 +7bfff58f00 +30 + +00 +00 +00 +00 +00 +00 +00 +00 +redzone + + +f3 +7bfff58f00 +38 + +00 +80 +8e +f5 +ff +7b +00 +00 +redzone + + +rbp + +7fffffffecc0 + +e0 +ec +ff +ff +ff +7f +00 +00 +saved rbp + + +7fffffffece0 +7fffffffecc8 + +54 +3c +52 +00 +00 +00 +00 +00 +return + + +523c54 +main+20 + + + +fill + + +i 27 · moment 252 · asan exited +i = 27: the return address is half 41s, and reads +41414141, no longer an address. ASan stopped at i = 16. + diff --git a/design/mock/39-minimap-1to1.png b/design/mock/39-minimap-1to1.png new file mode 100644 index 0000000..25cf6e2 Binary files /dev/null and b/design/mock/39-minimap-1to1.png differ diff --git a/design/mock/context.py b/design/mock/context.py index d58683c..31a54f6 100644 --- a/design/mock/context.py +++ b/design/mock/context.py @@ -98,8 +98,13 @@ def held_cell(g, x, y, w, h, k=1): g.rect(x, y + h - 3 * k, w, 3 * k, mix(VERM, PAGE, 0.6)) +MINIMAP = 0 # a pane with its own minimap: the frame this much wider than its content + + def tag(g, x, y, w, h, title, focus=False, note=None): - """A panel's frame and its one-row tag. note: a string, or runs (text, ink, underlined) for a legend.""" + """A panel's frame and its one-row tag. note: a string, or runs (text, ink, underlined) for a legend. The frame + is MINIMAP wider than w: the pane's minimap strip is drawn in it, right of the content (map.py).""" + w += MINIMAP g.rect(x, y, w, TAG, RAISED) g.frame(x, y, w, h, DIM if focus else RULE, 2) if focus: diff --git a/design/mock/map.py b/design/mock/map.py index 1b4287b..65b6c88 100644 --- a/design/mock/map.py +++ b/design/mock/map.py @@ -18,8 +18,6 @@ import context as C from context import (PAGE, RAISED, RULE, VELLUM, BRIGHT, DIM, FAINT, GOLD, VERM, READ, HEAP, STACK, A, S, ROW, TAG, PAD, MONO, b, ph, tw, mix, Svg, H_) -MINI = (1664, 912, 192, 108) # the minimap's place in the working frame: x, y, w, h -K = 1 / 20 # map units to the minimap's RSP, UNDER = D.RSP, 16 # the map's stack starts 16 words above rsp ROLES = {0: "saved rbp", 3: "saved rbx", 4: "saved rbp", 26: "saved rbp", 38: "saved rbp", 42: "argc", 43: "argv[0]", 44: "argv end", 45: "envp end", 46: "auxv"} @@ -87,6 +85,9 @@ def pins(step): return {0x10040b0: ["rcx"], 0x1004090: ["rax"] + ([] if step else ["rdi"]), 0x1004070: ["rdi"] if step else []} +COLS = {} # a pane's column on the map: (its parts, its window's first row, rows) + + def draw_map(g, step, loupe, subject=False): """The map at one moment. Returns the outlines of the working frame's windows, in map units.""" stage(True) @@ -100,6 +101,7 @@ def draw_map(g, step, loupe, subject=False): win["drawing"] = (col[0], 96, D.CW, 296) ys = C.source(g, 404, 42, D.SRC, 1, 21, [], "list.c", 42) first = 18 if subject else 19 + COLS["source"] = ([(col[0], 404 + TAG + PAD, 42)], first - 1, sp["src"]) win["source"] = (col[0], 404 + TAG + PAD + (first - 1) * ROW, D.CW, sp["src"] * ROW) D.put(col[0]) C.backtrace(g, 1456, ph(5), D.BT, x=col[0], note="newest at the bottom") @@ -111,12 +113,14 @@ def draw_map(g, step, loupe, subject=False): D.thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)]) wn = [r[0] for r in D.window(sp["dis"], step)] win["disasm"] = (col[1], at[wn[0]], D.CW, sp["dis"] * ROW) + COLS["disasm"] = ([(col[1], 96 + TAG + PAD, 69)], [r[0] for r in rows].index(wn[0]), sp["dis"]) # C: memory, the registers, a loupe, the stack continued D.put(col[2]) mem = C.fields(g, 96, ph(14), "the heap, round what the step reads", 0x1004000, 512, D.heap_fields(0x1004000, 512, 0x1004098), D.MEM, HEAP, D.region, marks=(9,) if step else (), title="memory", touched={0x1004098} if step else ()) win["view"] = (col[2], mem[0x1004050 if subject else 0x1004070], D.CW, (7 if subject else 5) * ROW) + COLS["view"] = ([(col[2], 96 + TAG + PAD, 14)], (win["view"][1] - 96 - TAG - PAD) // ROW, 7 if subject else 5) C.registers(g, 476, D.regs(step), D.FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike" if step else "tick"}}) win["registers"] = (col[2], 476, D.CW, ph(17)) @@ -131,6 +135,7 @@ def draw_map(g, step, loupe, subject=False): D.put(col[3]) C.stack(g, 96, slot_rows(0, 69), frames_from(0, 69), note="from rsp-80", rsp=RSP, roles=roles_from(0, 69)) win["stack"] = (col[3], 96 + TAG + PAD + UNDER * ROW, D.CW, sp["words"] * ROW) + COLS["stack"] = ([(col[3], 96 + TAG + PAD, 69), (col[2], y + TAG + PAD, n_c)], UNDER, sp["words"]) D.put(col[2]) C.stack(g, y, slot_rows(69, n_c - 1), frames_from(69, n_c - 1), note="continued", rsp=RSP, roles=roles_from(69, n_c - 1)) @@ -159,39 +164,58 @@ def key(g, x, y, step): g.t(xx + 136, b(yy), name, 18, DIM, "sans") -# ---- the minimap ------------------------------------------------------------------------------------------- -INKED = {GOLD, C.SOFT, VERM, C.WASH, RAISED, D.LIFT, D.LIFT_TAG, READ} - - -def minimap(g, log, windows, x0, y0, k=K, focus="drawing"): - """The map at k: every run of text a stroke 1 high in its ink at 45% toward the page; tags, paper and the - lift as blocks; the marks over them; the working frame's windows outlined, the one in focus 2.""" - W, H = 3840 * k, 2160 * k - g.rect(x0, y0, W, H, PAGE) - marks = [] - for e in log: - if e[0] == "r": - _, x, y, w, h, fill, stroke = e - if fill in (GOLD, C.SOFT, VERM) or stroke in (READ, VERM, BRIGHT): - marks.append(e) - elif fill in INKED and w * k >= 1: - g.rect(x0 + x * k, y0 + y * k, max(w * k, 1), max(h * k, 1), mix(fill, PAGE, 0.7 if fill == RAISED else 0.6)) - elif stroke in (RULE, DIM) and w > 200: - g.frame(x0 + x * k, y0 + y * k, w * k, h * k, mix(RULE, PAGE, 0.8), 1) - elif e[2] < 2100 and e[5] not in (None, "none"): - _, x, y, w, size, fill = e - g.rect(x0 + x * k, y0 + (y - size * 0.62) * k, max(w * k, 0.8), max(size * 0.05, 0.9), mix(fill, PAGE, 0.55)) - for _, x, y, w, h, fill, stroke in marks: # the marks: gold, a strike, a read; at least a pixel and a half - ink = fill if fill in (GOLD, C.SOFT, VERM) else stroke - if ink == C.SOFT: - ink = VERM - if ink == BRIGHT: - continue - g.rect(x0 + x * k, y0 + y * k, max(w * k, 1.5), max(h * k, 1.5), ink) - for name, (x, y, w, h) in windows.items(): - g.frame(x0 + (x - 4) * k, y0 + (y - 4) * k, (w + 8) * k, (h + 8) * k, BRIGHT if name == focus else VELLUM, - 1.5 if name == focus else 1) - g.frame(x0, y0, W, H, RULE, 1) +# ---- a pane's minimap ------------------------------------------------------------------------------------ +MW, MGAP, MR = 40, 8, 4 # its strip: 40 wide, 8 from the content; 4 units a row +KX = (MW - 4) / D.CW # a row's 880 to the strip's 36: a character two thirds of a unit + + +def column(log, parts): + """A pane's column, from the map's log: for each row, its runs of text as (x from the panel's left, width, + ink), and its marks (current, struck, read).""" + rows, marks, n0 = {}, {}, 0 + for x0, y0, n in parts: + for e in log: + if e[0] == "t": + _, x, y, w, size, fill = e + r = int((y - 19.2 - y0 + 1) // ROW) + if x0 <= x < x0 + D.CW and 0 <= r < n and fill not in (None, "none", PAGE): + rows.setdefault(n0 + r, []).append((x - x0, w, fill)) + else: + _, x, y, w, h, fill, stroke = e + r = int((y + h / 2 - y0) // ROW) + if not (x0 <= x < x0 + D.CW and 0 <= r < n): + continue + kind = ("current" if fill in (GOLD, C.WASH) and w >= 20 and h >= 20 else + "struck" if fill in (C.SOFT, VERM) else "read" if stroke == READ else None) + if kind: + marks.setdefault(n0 + r, set()).add(kind) + n0 += n + return rows, marks, n0 + + +def pane_minimap(g, log, name, x, y, h): + """A pane's minimap: its whole column of the map, a row 4 units, in the strip at the pane's right (x, y, 40 by + h). Each run of text a stroke 3 high in its ink 65% of the way from the page; the marks at the row's left: the current + row gold, a strike vermilion, a read in read's colour; the pane's window framed 2 in `dim`. A column longer + than the strip shows the rows round the window, and three dots at the end where it goes on.""" + parts, w0, wn = COLS[name] + rows, marks, total = column(log, parts) + g.rect(x, y, MW, h, C.WELL) + cap = int((h - 6) // MR) + first = 0 if total <= cap else min(max(w0 + wn // 2 - cap // 2, 0), total - cap) + top = y + 3 + for r in range(first, min(first + cap, total)): + ry = top + (r - first) * MR + for rx, rw, ink in rows.get(r, []): + g.rect(x + 2 + rx * KX, ry, max(rw * KX, 1), 3, mix(ink, PAGE, 0.65)) + for k, kind in enumerate(sorted(marks.get(r, ()), key=["current", "struck", "read"].index)): + g.rect(x + 2 + 5 * k, ry - 0.5, 4, 4, {"current": GOLD, "struck": VERM, "read": READ}[kind]) + g.frame(x, top + (w0 - first) * MR - 3, MW, wn * MR + 5, VELLUM, 2) # the pane's window + for end, more in (("top", first > 0), ("foot", first + cap < total)): + if more: + yy = y + 1 if end == "top" else y + h - 3 + for d in range(3): + g.rect(x + MW / 2 - 7 + d * 6, yy, 2, 2, FAINT) def map_log(step, loupe, subject=False): @@ -209,7 +233,13 @@ SUBJECT_VIEW = [5, 6, 7, 8, 9, 10, 11] def clock(g, moment, total): g.rect(64, 899, 1792, 2, RULE) g.rect(64, 898, 1792 * moment / total, 4, GOLD) - g.t(MINI[0] - 16, 934, "moment %d of %d" % (moment, total), S, FAINT, MONO, "end") + g.t(1856, 934, "moment %d of %d" % (moment, total), S, FAINT, MONO, "end") + + +def strip(on): + """Panes with a minimap: their content 48 narrower, their frame whole (context.tag).""" + C.CW, C.MINIMAP = (D.CW - MW - MGAP, MW + MGAP) if on else (D.CW, 0) + C.DX_NOTE = 540 if on else 564 # the annotation starts 24 sooner, so its room loses only 24 def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None): @@ -225,6 +255,7 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None): y = 48 + sp["band"] + 12 c = open_("source") + strip(True) D.put(64) ys = C.source(g, y, sp["src"], D.SRC, 18 if subject else 19, 21, [], "list.c", 42) g.o.append(c) if c else None @@ -234,10 +265,12 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None): out["thread"] = (ys, at[0x1001926]) yr = 48 + sp["view"] + 12 c = open_("registers") + strip(False) D.put(976) out["regs"] = C.registers(g, yr, D.regs(step), D.FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike" if step else "tick"}}) g.o.append(c) if c else None + strip(True) c = open_("stack") n = sp["words"] C.stack(g, yr + ph(17) + 12, slot_rows(UNDER, n), frames_from(UNDER, n), rsp=RSP, roles=roles_from(UNDER, n)) @@ -248,7 +281,10 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None): marks=(9,) if step else (), rows_shown=SUBJECT_VIEW if subject else BESIDE_VIEW, more_rows=False, touched={0x1004098} if step else (), withhold=withhold) g.o.append(c) if c else None + strip(False) out["view"] = view + out["boxes"] = {"source": (64, y, ph(sp["src"])), "disasm": (64, y + ph(sp["src"]) + 12, ph(sp["dis"])), + "stack": (976, yr + ph(17) + 12, ph(n)), "view": (976, 48, sp["view"])} return out, sp @@ -272,12 +308,19 @@ def working(name, step, subject=False, loupe=False, caption=None): D.loupe(g, lx, ly, [("rdi", DIM), (" → ", FAINT), ("1004070", HEAP)], "heap · struct node, 16 bytes", 0x1004050, D.heap_fields(0x1004050, 80), [(0x1004070 - 0x1004050, 16)], 1, rows=5) g.rect(hop - 2, ry + ROW - 3, 7 * A + 4, 4, HEAP) # the stem, short: a bracket under the pointer's digits, on the tag - minimap(g, m.log, win, *MINI[:2], focus="loupe" if loupe else "drawing") + minimaps(g, m.log, out["boxes"]) clock(g, 3 if step else 2, 4) gen.caption(g, caption) g.save(name) +def minimaps(g, log, boxes, skip=()): + """Each pane's minimap, in the strip its frame keeps at its right, over its body.""" + for name, (x, y, h) in boxes.items(): + if name not in skip: + pane_minimap(g, log, name, x + D.CW - 2 - MW, y + TAG, h - TAG - 2) + + # ---- the dive: the map coming in to the working frame, four instants ------------------------------------- def glide(t): """The glide curve (0.45, 0, 0.55, 1), solved for t.""" @@ -294,15 +337,17 @@ FRAME_RECT = {"source": (64, 212, 880, ph(8)), "disasm": (64, 448, 880, ph(17)), def dive(name, e, veil, outline, fade_frame): - """One instant of `dive`: e, the move's progress (glide applied), veil on the map, the windows' outline, how - far the working frame's own tags and minimap have come in.""" + """One instant of `dive`: e, the move's progress (glide applied); veil, on the map; outline, the windows' bright + frames; fade_frame, how far the working frame's tags and minimaps have come in. Each window travels to its + pane's place, its scale from the map's half to whole on its logarithm; each pane's column, the rest of what + the map holds of it, squeezes into the pane's minimap strip on the same move; the rest of the map fades.""" m, win = map_log(False, False) - body = m.o[1:] # the map's drawing, its page and all, without its svg head + body = m.o[1:-1] if m.o[-1] == "" else m.o[1:] stage(False) g = Svg() - sm = 0.5 ** (1 - e) * K ** e # the map: from filling the frame to the minimap, on the log of its scale - tx, ty = MINI[0] * e, MINI[1] * e - g.o.append('' % (tx, ty, sm)) + clips = [] + # the map's parts no pane takes: faded in place as the move goes + g.o.append('' % (1 - e)) g.o += body if veil: g.o.append('' % (PAGE, veil)) @@ -311,7 +356,29 @@ def dive(name, e, veil, outline, fade_frame): g.o.append('' % (x - 4, y - 4, w + 8, h + 8, BRIGHT, 2 + outline * 2)) g.o.append("") - # each window: the working panel, from its place on the map to its own, its scale on a logarithm + out, sp = working_panels(Svg(), False, False) # where the panes and their strips will be + if 0 < e < 1: # each column squeezing into its strip: a row from 24 units to 3 + for nm, (bx, by, bh) in out["boxes"].items(): + parts, w0, wn = COLS[nm] + sx0, sy0 = bx + D.CW - 2 - MW + 2, by + TAG + 3 + cap = int((bh - TAG - 2 - 6) // MR) + total = sum(p[2] for p in parts) + first = 0 if total <= cap else min(max(w0 + wn // 2 - cap // 2, 0), total - cap) + n0 = 0 + for k, (mx, my, n) in enumerate(parts): + kx, ky = 0.5 ** (1 - e) * KX ** e, 0.5 ** (1 - e) * (MR / ROW) ** e # on their logarithms + tx = mx * 0.5 * (1 - e) + sx0 * e + ty = my * 0.5 * (1 - e) + (sy0 + (n0 - first) * MR) * e + cid = "c%s%d" % (nm, k) + clips.append('' + % (cid, mx, my, D.CW, n * ROW)) + g.o.append('' + % (0.5 + 0.5 * e, tx, ty, kx, ky, -mx, -my)) + g.o.append('' % cid) + g.o += body + g.o.append("") + n0 += n + g.o.insert(1, "" + "".join(clips) + "") map_rect = {"source": win["source"], "disasm": win["disasm"], "registers": win["registers"], "stack": win["stack"], "view": win["view"], "drawing": win["drawing"]} @@ -320,8 +387,6 @@ def dive(name, e, veil, outline, fade_frame): return "", "" fx, fy, fw, fh = FRAME_RECT[nm] mx, my, mw, mh = map_rect[nm] - # at e = 0 the panel's first row lies on its window's first row on the map, both at half size; at e = 1 - # the panel is at its own place and size. Scale on its logarithm, the offset with the move. row0 = fy if nm in ("registers", "drawing") else fy + TAG + PAD sw = 0.5 ** (1 - e) ox, oy = (mx - fx) * 0.5 * (1 - e), (my - row0) * 0.5 * (1 - e) @@ -338,7 +403,7 @@ def dive(name, e, veil, outline, fade_frame): g.o.append(c) if fade_frame > 0: g.o.append('' % fade_frame) - minimap(g, m.log, win, *MINI[:2]) + minimaps(g, m.log, out["boxes"]) clock(g, 2, 4) g.o.append("") gen.caption(g, [[("Stopped in ",), ("reverse", "mono"), (", about to load ",), ("head->next", "mono"), (".",)], @@ -363,6 +428,28 @@ def sheet(names, out, labels): s.save(out) +def crop_sheet(src, out): + """Mock 39: three panes' right ends from a working frame, at 1:1 (a 1080p pixel a unit), with what each minimap + lets a viewer read named under it.""" + im = Image.open(src).convert("RGB") + crops = [((800, 448, 944, 888), (24, 64), "the disassembly", ["69 rows: the function whole", "and its neighbours; the pc", + "gold, a read cyan; the", "window of 17 rows framed"]), + ((1640, 40, 1860, 200), (380, 64), "its bytes", ["the heap's 14 rows on the map;", "the 5 shown framed; the read row"]), + ((1640, 660, 1860, 888), (380, 360), "the stack", ["48 of its 103 rows, round the", "window; three dots: it goes on"])] + s = Image.new("RGB", (720, 700), "#0a1030") + d = ImageDraw.Draw(s) + head = ImageFont.truetype("/usr/share/fonts/go/Go-Medium.ttf", 22) + body = ImageFont.truetype("/usr/share/fonts/go/Go-Regular.ttf", 18) + d.text((24, 18), "each pane's minimap at 1:1, a pixel of 1080p a unit", font=head, fill="#eee6d2") + for box, (x, y), name, lines in crops: + c = im.crop(box) + s.paste(c, (x, y)) + d.text((x, y + c.height + 10), name, font=head, fill="#eee6d2") + for k, t in enumerate(lines): + d.text((x, y + c.height + 40 + 24 * k), t, font=body, fill="#9aa6d9") + s.save(out) + + if __name__ == "__main__": import os stage(True) @@ -381,7 +468,8 @@ if __name__ == "__main__": working("11-context-lens", True, subject=True, caption=cap10) working("21-loupe", True, loupe=True, caption=[[("rdi", "mono"), (" holds ",), ("1004070", "mono"), ("; under it opens the heap round that node.",)], - [("The minimap shows the same loupe at its place on the map.",)]]) + [("Each pane's minimap shows where its rows are in the whole.",)]]) + crop_sheet("10-context-step.png", "39-minimap-1to1.png") names = ["20a", "20b", "20c", "20d"] dive("20a", 0, 0, 0, 0) dive("20b", 0, 0.5, 1, 0) diff --git a/design/mock/pair.py b/design/mock/pair.py index 1311b95..3adb60d 100644 --- a/design/mock/pair.py +++ b/design/mock/pair.py @@ -102,12 +102,188 @@ def source_pair(g, cur_l, cur_r, waiting_r=False): return ys -def frame(name, part): - """The pair at the loop. part=False: i = 15, both builds at the line's store (plain) and its check (asan). - part=True: i = 16, the step in which they part: plain's store struck into the saved rbp; asan's check read f3.""" +# ---- the frame as bytes: `hexdump` `eight`, by the frame's own fields -------------------------------------------- +PX, AX, BX8, RD = 12, 118, 274, 522 # a row: the pin lane, the address, eight bytes 30 apart, the reading +SHX = 62 # in a run with ASan, the row's shadow byte, in the pin lane's end + + +def plain_region(v): + """Where a word of the plain build points, by its mappings; None: nowhere (a number).""" + if 0x7ffffffde000 <= v < 0x7ffffffff000: + return S_ + if 0x401000 <= v < 0x402000: + return C_ + if 0x404000 <= v < 0x405000: + return D_ + return None + + +def asan_region(v): + if 0x7ffffffde000 <= v < 0x7ffffffff000: + return S_ + if 0x7bfff58e7000 <= v < 0x7bfff6400000: + return D_ + if 0x42c000 <= v < 0x524000: + return C_ + if 0x524000 <= v < 0x55f000: + return VELLUM + return None + + +CODE_NAMES = {0x401120: "main", 0x401140: "fill", 0x523c40: "main", 0x523c60: "fill"} + + +def code_name(v): + f = max((a for a in CODE_NAMES if a <= v and v - a < 0x100), default=None) + return None if f is None else (CODE_NAMES[f] + ("+%d" % (v - f) if v > f else "")) + + +def plain_mem(stored, i): + """The plain build's stack from 7fffffffecb0 to 7fffffffed00 after `stored` of the loop's stores, i in its slot.""" + m = {a: 0 for a in range(0x7fffffffecb0, 0x7fffffffed00)} + for k, v in enumerate([0x00, 0xed, 0xff, 0xff, 0xff, 0x7f, 0, 0, 0x34, 0x11, 0x40, 0, 0, 0, 0, 0]): + m[0x7fffffffece0 + k] = v + for k in range(4): + m[0x7fffffffeccc + k] = i >> (8 * k) & 0xff + for k in range(stored): + m[0x7fffffffecd0 + k] = 0x41 + return m + + +def asan_mem(stored): + """ASan's fake frame (the header as its prologue wrote it, buf, the redzone) and the real stack's way back.""" + m = {} + for off, v in [(0, 0x41b58ab3), (8, 0x5387a7), (0x10, 0x523c60), (0x18, 0x7fffffffec10), (0x38, 0x7bfff58e8000)]: + for k in range(8): + m[FAKE + off + k] = v >> (8 * k) & 0xff + for k in range(0x20, 0x38): + m[FAKE + k] = 0x41 if 0x20 <= k < 0x20 + stored else 0 + for a, v in [(0x7fffffffecc0, 0x7fffffffece0), (0x7fffffffecc8, 0x523c54)]: + for k in range(8): + m[a + k] = v >> (8 * k) & 0xff + return m + + +DESCR = {0x5387a7: "1 32 16 5 buf:3"} + + +def frame_dump(g, x, y, title, note, rows, mem, region, pins=None, shadow=None, struck=None, held=(), letters=(), + read_shadow=None, span=None, rule_after=None, differs=(), seam=None): + """`hexdump` `eight` by the frame's fields: a row a word of the stack (eight bytes), its pins and address, the + bytes on their field's paper, the reading: the field's name (Go 18, dim) and what its type makes of its bytes. + rows: (address, [(offset, length, reads, name)]); reads in text | pointer | number | bytes; what no field + covers is loose. letters: bytes stored past the field the store aimed at, which keep its ink (text) wherever + they land. shadow: {row: byte}. span: (name, first row, last row). Returns the rows' y.""" + pins = pins or {} + y0 = C.panel(g, x, y, C.CW, len(rows) + (0 if rule_after is None else 0), title, note=note) + lead = C.shared([a for a, _ in rows if region(a) == region(rows[0][0])]) + ys = [] + for r, (a0, flist) in enumerate(rows): + yy = y0 + r * ROW + ys.append(yy) + if rule_after is not None and r == rule_after + 1: # another region (the real stack): a rule before it + g.rect(x + 2, yy - 1, C.CW - 4, 2, RULE) + if r in pins: + C.pin(g, x + PX, yy, pins[r], S_) + if shadow and r in shadow: + shadow_cell(g, x + SHX, yy, shadow[r], read=read_shadow == r) + ink_a = region(a0) or VELLUM + C.addr(g, x + AX, yy, a0, ink_a, lead=lead if region(a0) == region(rows[0][0]) else 0) + bx = lambda k: x + BX8 + 30 * k + covered = {} + for f in flist: + for k in range(f[0], f[0] + f[1]): + covered[k] = f + rx = x + RD + for f in flist: + off, n, reads, name = f + vals = [mem[a0 + off + k] for k in range(n)] + word = sum(v << (8 * k) for k, v in enumerate(vals)) + g.rect(bx(off) - 4, yy + 1, 30 * n - 2, ROW - 2, RAISED) + ink = {"text": LIT, "number": VELLUM, "bytes": VELLUM, "pointer": region(word) or VELLUM}[reads] + nz = [k for k, v in enumerate(vals) if v] + for k, v in enumerate(vals): + a = a0 + off + k + xx = bx(off + k) + if a == struck: + g.t(xx, b(yy), "%02x" % v, S, C.struck(g, xx - 5, yy, 34), BOLD) + continue + if a in held: + C.held(g, xx, yy, 24) + padded = reads in ("number", "pointer") and nz and k > nz[-1] + kink = LIT if a in letters else ink + g.t(xx, b(yy), "%02x" % v, S, mix(kink, PAGE, 0.45) if padded else kink, MONO) + # the reading: the field's name, then its value + g.t(rx, b(yy) - 1, name, 18, DIM, "sans") + vx = rx + gen.tw(name, 18, "sans") + 10 + if reads == "text": + s_ = '"' + bytes(v for v in vals).split(b"\0")[0].decode("latin1") + '"' + g.t(vx, b(yy), s_, S, LIT, MONO) + elif reads == "number": # a count: in decimal, as the source writes it + g.t(vx, b(yy), str(word), S, VELLUM, MONO) + elif reads == "pointer": + ink_w = region(word) + if ink_w: + vx = C.addr(g, C.link_arrow(g, vx, yy), yy, word, ink_w) + nm = code_name(word) if ink_w == C_ else None + if nm: + g.t(vx + 10, b(yy), nm, S, VELLUM, MONO) + elif word in DESCR: + room = int((x + C.CW - 24 - vx - 10) // A) + t_ = '"%s"' % DESCR[word] + g.t(vx + 10, b(yy), t_ if len(t_) <= room else t_[:room - 1] + "…", S, LIT, MONO) + else: # no longer an address: a number, no arrow, no name + g.t(vx, b(yy), "0x%x" % word, S, VELLUM, MONO) + rx = vx + 200 + for k in range(8): # what no field covers: loose + if k not in covered: + v = mem.get(a0 + k) + g.t(bx(k), b(yy), "%02x" % v, S, mix(DIM, PAGE, 0.6), MONO) + if r in differs: + bar(g, seam, yy, BRIGHT) + if span: # the frame's span, as the stack's: a bracket 14 in, its name left of it + name, r0, r1 = span + bx_, ya, yb = x + C.CW - 14, ys[r0] + 3, ys[r1] + ROW - 3 + g.rect(bx_ - 1, ya, 2, yb - ya, GOLD) + g.rect(bx_ - 7, ya, 8, 2, GOLD) + g.rect(bx_ - 7, yb - 2, 8, 2, GOLD) + g.t(bx_ - 14, (ya + yb) / 2 + 6, name, 18, BRIGHT, "sansm", "end") + return ys + + +PLAIN_ROWS = [(0x7fffffffecb0, []), (0x7fffffffecb8, []), (0x7fffffffecc0, []), + (0x7fffffffecc8, [(4, 4, "number", "i")]), (0x7fffffffecd0, [(0, 8, "text", "buf[0..7]")]), + (0x7fffffffecd8, [(0, 8, "text", "buf[8..15]")]), (0x7fffffffece0, [(0, 8, "pointer", "saved rbp")]), + (0x7fffffffece8, [(0, 8, "pointer", "return")]), (0x7fffffffecf0, []), (0x7fffffffecf8, [])] +ASAN_ROWS = [(FAKE, [(0, 8, "bytes", "magic")]), (FAKE + 8, [(0, 8, "pointer", "descr")]), + (FAKE + 0x10, [(0, 8, "pointer", "pc")]), (FAKE + 0x18, [(0, 8, "pointer", "real stack")]), + (FAKE + 0x20, [(0, 8, "text", "buf[0..7]")]), (FAKE + 0x28, [(0, 8, "text", "buf[8..15]")]), + (FAKE + 0x30, [(0, 8, "bytes", "redzone")]), (FAKE + 0x38, [(0, 8, "bytes", "redzone")]), + (0x7fffffffecc0, [(0, 8, "pointer", "saved rbp")]), (0x7fffffffecc8, [(0, 8, "pointer", "return")])] +SHADOW = {0: 0xf1, 1: 0xf1, 2: 0xf1, 3: 0xf1, 4: 0, 5: 0, 6: 0xf3, 7: 0xf3} + + +def plain_dump(g, i, stored, struck=None, held=(), note="fill's frame as bytes, eight a row"): + letters = {0x7fffffffecd0 + k for k in range(16, stored)} + return frame_dump(g, LEFT, 612, "plain · stack", note, PLAIN_ROWS, plain_mem(stored, i), plain_region, + pins={6: ["rbp", "rsp"]}, struck=struck, held=held, letters=letters, span=("fill", 3, 7), + differs=(6, 7), seam=LEFT + 880 - 6) + + +def asan_dump(g, stored, read=False): + return frame_dump(g, RIGHT, 612, "asan · fake frame", "its shadow at addr >> 3 + 7fff8000 · then the real " + "stack's way back", ASAN_ROWS, asan_mem(stored), asan_region, pins={8: ["rbp"]}, shadow=SHADOW, + read_shadow=6 if read else None, span=("fill", 0, 9), rule_after=7, differs=(6, 7), + seam=RIGHT + 2) + + +def frame(name, i): + """The pair at the loop, the frame as bytes in each column. i = 15: both builds at the line's store (plain) + and its check (asan). i = 16: the step in which they part: plain's store struck into the saved rbp; asan's + check read f3.""" gen.W, gen.H = 1920, 1080 g = Svg() - i = 16 if part else 15 + part = i == 16 source_pair(g, 4, 4) # ---- the left column: plain ---- at_side(LEFT) @@ -119,16 +295,8 @@ def frame(name, part): [("rax", [], ("int", i)), ("rbp", [(0x7fffffffece0, S_), (0x7fffffffed41 if part else 0x7fffffffed00, S_)], None), ("rsp", [(0x7fffffffece0, S_)], None), ("rip", [(0x401155, C_, "fill+21")], None)], {"rax": {0: "tick"}}) - sv = 0x7fffffffed41 if part else 0x7fffffffed00 - prow = [(0x7fffffffecb0, [], [], ("int", 0)), (0x7fffffffecb8, [], [], ("int", 0)), - (0x7fffffffecc0, [], [], ("int", 0)), (0x7fffffffecc8, [], [], ("int", i << 32)), - (0x7fffffffecd0, [], [], ("str", "AAAAAAAA")), (0x7fffffffecd8, [], [], ("str", "AAAAAAA" if not part else "AAAAAAAA")), - (0x7fffffffece0, ["rbp", "rsp"], [(sv, S_)], None) + (({1: "strike"},) if part else ()), - (0x7fffffffece8, [], [(0x401134, C_, "main+20")], None), - (0x7fffffffecf0, [], [], ("int", 0)), (0x7fffffffecf8, [], [], ("int", 0))] - py = C.stack(g, 612, prow, [("fill", 3, 7)], note="red zone, buf, the frame · rsp at +0", rsp=0x7fffffffece0, - roles={3: ("i, high half", VELLUM), 4: ("buf[0..7]", VELLUM), 5: ("buf[8..15]", VELLUM), - 6: ("saved rbp", DIM), 7: ("return", DIM)}, title="plain · stack") + plain_dump(g, i, i + 1 if part else i, struck=0x7fffffffece0 if part else None, + held={0x7fffffffecdf, 0x7fffffffeccc} if part else {0x7fffffffecde, 0x7fffffffeccc}) # ---- the right column: asan ---- at_side(RIGHT) an = {0x523d38: ("chain", [(0xf807eb16006 if part else 0xf807eb16005, D_)], ("int", 0xf3 if part else 0), @@ -138,53 +306,89 @@ def frame(name, part): if part: an[0x523d41] = ("runs", [("f3", VELLUM), (" : ", FAINT), ("0", VELLUM), (" ", FAINT), ("zf", DIM)]) an[0x523d43] = ("runs", [("not taken", DIM)]) - ar = rows_of(ASAN, 0x523d26, 9, ast, an) - at = C.disasm(g, 212, ar, "asan · fill", 4) + at = C.disasm(g, 212, rows_of(ASAN, 0x523d26, 9, ast, an), "asan · fill", 4) for a, yy in at.items(): if a in ONLY: bar(g, RIGHT + 2, yy, DIM) # its seam is on its left regs(g, RIGHT, 472, "asan · registers", [("rax", [], ("int", (FAKE + 0x20 + i) >> 3)), ("rbx", [(0x7fffffffec20, S_), (FAKE + 0x20 + i, D_)], None), ("rcx", [], ("int", i)), ("rip", [(0x523d38, C_, "fill+216")], None)], {"rax": {0: "tick"}}) - arow = [(FAKE + 0x00, [], [], ("int", 0x41b58ab3)), (FAKE + 0x08, [], [(0x5387a7, VELLUM)], ("str", "1 32 16 5 buf:3")), - (FAKE + 0x10, [], [(0x523c60, C_, "fill")], None), (FAKE + 0x18, [], [(0x7fffffffec10, S_)], None), - (FAKE + 0x20, [], [], ("str", "AAAAAAAA")), (FAKE + 0x28, [], [], ("str", "AAAAAAA" if not part else "AAAAAAAA")), - (FAKE + 0x30, [], [], ("int", 0)), (FAKE + 0x38, [], [(0x7bfff58e8000, D_)], None)] - ay = C.stack(g, 612, arow + [(0x7fffffffecc0, ["rbp"], [(0x7fffffffece0, S_)], None), - (0x7fffffffecc8, [], [(0x523c54, C_, "main+20")], None)], - [("fill", 0, 9)], note="the fake frame, its shadow · the real stack's way back", rsp=None, - roles={0: ("magic", DIM), 1: ("descr", DIM), 2: ("pc", DIM), 3: ("real stack", DIM), - 4: ("buf[0..7]", VELLUM), 5: ("buf[8..15]", VELLUM), 6: ("redzone", DIM), 7: ("redzone", DIM), - 8: ("saved rbp", DIM), 9: ("return", DIM)}, title="asan · fake stack", - ink_of=lambda a: S_ if a >= 0x7ffffffde000 else D_) - sh = [0xf1, 0xf1, 0xf1, 0xf1, 0, 0, 0xf3, 0xf3] - ys = sorted(ay.values()) if isinstance(ay, dict) else ay - base_y = 612 + TAG + PAD - for k, v in enumerate(sh): - shadow_cell(g, RIGHT + 88, base_y + k * ROW, v, read=part and k == 6) - # the real stack is another region: a rule before its two rows - g.rect(RIGHT + 2, base_y + 8 * ROW, C.CW - 4, 2, RULE) - # `differs`: the rows that face each other across the seam and hold different things (buf's end: saved rbp vs redzone) - for k in (6, 7): - bar(g, LEFT + 880 - 6, base_y + k * ROW, BRIGHT if part or k == 6 else BRIGHT) - bar(g, RIGHT + 2, base_y + k * ROW, BRIGHT) - # the clock: one rule, each run's moment - g.rect(64, 899, 1792, 2, RULE) - g.rect(64, 898, 1792 * (17 if part else 16) / 33, 4, GOLD) - g.t(1648, 934, "i %d · moments %d / %d" % (i, 164 if part else 156, 770 if part else 753), S, FAINT, MONO, "end") + asan_dump(g, 16 if part else 15, read=part) + clock(g, 17 if part else 16, "i %d · moments %d / %d" % (i, 164 if part else 156, 770 if part else 753)) if part: - gen.caption(g, [[("i = 16, one past ",), ("buf", "mono"), (": plain writes ",), ("'A'", "mono"), - (" into the saved rbp. ASan reads",)], - [("the shadow first: ",), ("f3", "mono"), (", a redzone. Its branch to the store is not taken.",)]]) + gen.caption(g, [[("i = 16, one past ",), ("buf", "mono"), (": plain writes ",), ("41", "mono"), + (", an ",), ("'A'", "mono"), (", into the saved rbp.",)], + [("ASan reads the shadow first: ",), ("f3", "mono"), (", a redzone. It does not store.",)]]) else: - gen.caption(g, [[("The same line, two builds: plain stores the byte; ASan first",)], - [("reads the byte of shadow that stands for it: ",), ("00", "mono"), (", so it may.",)]]) + gen.caption(g, [[("Each turn is one more byte: ",), ("41", "mono"), (", the letter ",), ("A", "mono"), + (". Fifteen in ",), ("buf", "mono"), (",",)], + [("on both sides; ASan read ",), ("00", "mono"), (" in the shadow before each one.",)]]) + g.save(name) + + +def clock(g, steps, text): + g.rect(64, 899, 1792, 2, RULE) + g.rect(64, 898, 1792 * steps / 33, 4, GOLD) + g.t(1648, 934, text, S, FAINT, MONO, "end") + + +REPORT = [("==1438870==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7bfff58f0030 at pc 0x000000523d5b", + "stack-buffer-overflow"), + ("WRITE of size 1 at 0x7bfff58f0030 thread T0", "WRITE of size 1"), + ("Address 0x7bfff58f0030 is located in stack of thread T0 at offset 48 in frame", None), + (" This frame has 1 object(s):", None), + (" [32, 48) 'buf' (line 3) <== Memory access at offset 48 overflows this variable", "[32, 48) 'buf'"), + ("=>0x7bfff58f0000: f1 f1 f1 f1 00 00[f3]f3 00 00 00 00 00 00 00 00", "[f3]")] + + +def report(g, x, y, lines): + """A run's stderr, as written: a panel of its lines, the ones the narration names framed; cut at its edge.""" + y0 = C.panel(g, x, y, C.CW, len(lines), "asan · stderr", note="its report, as written · exit 1") + room = (C.CW - 24) // A + for k, (t, mark) in enumerate(lines): + yy = y0 + k * ROW + s_ = t if len(t) <= room else t[:room - 1] + "…" + g.t(x + 12, b(yy), s_, S, VELLUM, MONO) + if mark and mark in s_: + c = s_.index(mark) + g.frame(x + 12 + c * A, yy, len(mark) * A, ROW, BRIGHT, 2) + + +def frame_ret(name): + """Mock 38: i = 27, plain alone: its store struck into the return address's fourth byte, which now reads + 0x41414141, no longer an address; ASan stopped at i = 16, its report in place of its registers.""" + gen.W, gen.H = 1920, 1080 + g = Svg() + source_pair(g, 4, 4) + at_side(LEFT) + pn = {0x401155: ("chain", [(0x7fffffffeceb, S_)], ("int", 0x41), {"end": "strike"})} + ps = {0x401155: "cur", 0x401151: "trail0", 0x40114f: "trail1", 0x40114b: "trail2"} + C.disasm(g, 212, rows_of(PLAIN, 0x401144, 9, ps, pn), "plain · fill", 4) + regs(g, LEFT, 472, "plain · registers", + [("rax", [], ("int", 27)), ("rbp", [(0x7fffffffece0, S_)], ("int", 0x4141414141414141)), + ("rsp", [(0x7fffffffece0, S_)], None), ("rip", [(0x401155, C_, "fill+21")], None)], + {"rax": {0: "tick"}}) + plain_dump(g, 27, 28, struck=0x7fffffffeceb, held={0x7fffffffece8, 0x7fffffffece9, 0x7fffffffecea, 0x7fffffffeccc}) + # ---- asan: stopped at i = 16. Its disassembly's upper rows, down to the call; its report in place of the rest + at_side(RIGHT) + ar = rows_of(ASAN, 0x523d4b, 5, {0x523d56: "trail0", 0x523d53: "trail1", 0x523d51: "trail2"}, + {0x523d56: ("text", "never returned", DIM)}) + at = C.disasm(g, 212, ar, "asan · fill · stopped", 4) + for a, yy in at.items(): + if a in ONLY: + bar(g, RIGHT + 2, yy, DIM) + report(g, RIGHT, 376, REPORT) + asan_dump(g, 16) + clock(g, 28, "i 27 · moment 252 · asan exited") + gen.caption(g, [[("i = 27: the return address is half ",), ("41", "mono"), ("s, and reads",)], + [("41414141", "mono"), (", no longer an address. ASan stopped at i = 16.",)]]) g.save(name) def sheet_store(name): """Mock 27: one turn of the loop, row by row, the plain build's rows facing their counterparts in the ASan - build's; the rows only ASan has barred on the seam side, the plain side's page facing them. i = 3.""" + build's; the rows only ASan has barred on the seam side, the plain side's page facing them. i = 3. Under + each, its buf as bytes: the turn's one byte struck, the letter it is.""" gen.W, gen.H = 1920, 1080 g = Svg() face = {0x40114b: 0x523d1e, 0x40114f: 0x523d22, 0x401151: 0x523d2a, 0x401155: 0x523d5e, 0x40115a: 0x523d61, @@ -217,8 +421,12 @@ def sheet_store(name): continue parts = [(ops, C_)] if isinstance(ops, int) else [(ops, P)] C.insn_rows(g, at[face[a]], [(a, ln if a == 0x40114b else None, mn, parts, None, pnotes.get(a))], 4, lead=4) - gaps = [a for a in order if a in ONLY and a not in skipped] g.t(LEFT + 400, at[0x523d34] + 18, "the check: plain has nothing here", 18, FAINT, "sans") + # the turn's one byte, in each build's buf: the store struck, the reading one letter longer + frame_dump(g, LEFT, 740, "plain · buf", "the turn's byte", PLAIN_ROWS[4:6], plain_mem(4, 3), plain_region, + struck=0x7fffffffecd3) + frame_dump(g, RIGHT, 740, "asan · buf", "its shadow, read before the store", ASAN_ROWS[4:6], asan_mem(4), + asan_region, shadow={0: 0, 1: 0}, read_shadow=0, struck=FAKE + 0x23) gen.caption(g, [[("Plain: one store. ASan: the address, its shadow byte (",), ("addr >> 3", "mono"), (" + ",), ("7fff8000", "mono"), ("),", )], [("a compare with 0, a branch; the partial check and the report only if it is not 0.",)]]) @@ -226,6 +434,7 @@ def sheet_store(name): if __name__ == "__main__": - frame("26-pair-rest", False) + frame("26-pair-rest", 15) sheet_store("27-pair-store") - frame("28-pair-part", True) + frame("28-pair-part", 16) + frame_ret("38-pair-ret") -- cgit v1.3