Skip to content

Fix integer overflow panic on large display - #15

Merged
const-void merged 1 commit into
const-void:masterfrom
sylr:fix-panic-large-screen
Dec 15, 2024
Merged

const-void merged 1 commit into
const-void:masterfrom
sylr:fix-panic-large-screen

Conversation

@sylr

@sylr sylr commented Nov 15, 2024

Copy link
Copy Markdown
Contributor
$ zig-out/bin/DOOM-fire
Screen size: 375w x 89h

Standard colors:
▏  0  ▏  1  ▏  2  ▏  3  ▏  4  ▏  5  ▏  6  ▏  7
▏  8  ▏  9  ▏ 10  ▏ 11  ▏ 12  ▏ 13  ▏ 14  ▏ 15

216 colors:
 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
 88 89 90 91 92 93 94 95 96 97 98 99100101102103104105106107108109110111112113114115116117118119120121122123
124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231

Grayscale:
▏232 ▏233 ▏234 ▏235 ▏236 ▏237 ▏238 ▏239 ▏240 ▏241 ▏242 ▏243 ▏244 ▏245 ▏246 ▏247 ▏248 ▏249 ▏250 ▏251 ▏252 ▏253 ▏254 ▏255

  How much is the fish?
             -- Scooter
Press return to continue...
thread 1068243 panic: integer overflow
/Users/sylvain/tmp/DOOM-fire-zig/src/main.zig:553:33: 0x104e7ab83 in showDoomFire (DOOM-fire)
    const FIRE_SZ: u16 = FIRE_H * FIRE_W;
                                ^
/Users/sylvain/tmp/DOOM-fire-zig/src/main.zig:695:17: 0x104e78d3b in main (DOOM-fire)
    showDoomFire();
                ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37: 0x104e789d3 in main (DOOM-fire)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x19b517153 in ??? (???)
???:?:?: 0xa04fffffffffffff in ??? (???)
[1]    68669 abort      zig-out/bin/DOOM-fire

```
$ zig-out/bin/DOOM-fire
Screen size: 375w x 89h

Standard colors:
▏  0  ▏  1  ▏  2  ▏  3  ▏  4  ▏  5  ▏  6  ▏  7
▏  8  ▏  9  ▏ 10  ▏ 11  ▏ 12  ▏ 13  ▏ 14  ▏ 15

216 colors:
 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
 88 89 90 91 92 93 94 95 96 97 98 99100101102103104105106107108109110111112113114115116117118119120121122123
124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231

Grayscale:
▏232 ▏233 ▏234 ▏235 ▏236 ▏237 ▏238 ▏239 ▏240 ▏241 ▏242 ▏243 ▏244 ▏245 ▏246 ▏247 ▏248 ▏249 ▏250 ▏251 ▏252 ▏253 ▏254 ▏255

  How much is the fish?
             -- Scooter
Press return to continue...
thread 1068243 panic: integer overflow
/Users/sylvain/tmp/DOOM-fire-zig/src/main.zig:553:33: 0x104e7ab83 in showDoomFire (DOOM-fire)
    const FIRE_SZ: u16 = FIRE_H * FIRE_W;
                                ^
/Users/sylvain/tmp/DOOM-fire-zig/src/main.zig:695:17: 0x104e78d3b in main (DOOM-fire)
    showDoomFire();
                ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37: 0x104e789d3 in main (DOOM-fire)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x19b517153 in ??? (???)
???:?:?: 0xa04fffffffffffff in ??? (???)
[1]    68669 abort      zig-out/bin/DOOM-fire
```

Signed-off-by: Sylvain Rabot <[email protected]>
@const-void
const-void merged commit e95b6d4 into const-void:master Dec 15, 2024
@const-void

Copy link
Copy Markdown
Owner

Thank you! Great fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants