-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
notcurses-demo: crash in 'view' when resizing the window #2471
Comments
woohoo! |
i have been unable to reproduce this yet, though i have crashed foot once =] =] |
|
having trouble reproducing this, but i just did an ASAN build, and it went all to hell on the first resize. let's see if i can collect anything useful from the debris... |
oh nope nevermind that was gdb stopping things because foot crashed lol |
man, even at your ridiculously small cell size, i can't reproduce this =\ |
ahhh, got it, yay =================================================================
==1126271==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f35eaa8a800 at pc 0x7f35f85389f9 bp 0x7ffd71dbd860 sp 0x7ffd71dbd858
READ of size 8 at 0x7f35eaa8a800 thread T0
#0 0x7f35f85389f8 in nccell_fg_alpha /home/dank/src/dankamongmen/notcurses/include/notcurses/notcurses.h:2615
#1 0x7f35f85389f8 in lock_in_highcontrast /home/dank/src/dankamongmen/notcurses/src/lib/render.c:420
#2 0x7f35f85389f8 in postpaint_cell /home/dank/src/dankamongmen/notcurses/src/lib/render.c:450
#3 0x7f35f85389f8 in postpaint /home/dank/src/dankamongmen/notcurses/src/lib/render.c:505
#4 0x7f35f8547e27 in ncpile_rasterize /home/dank/src/dankamongmen/notcurses/src/lib/render.c:1525
#5 0x5606f2b9692c in notcurses_render /home/dank/src/dankamongmen/notcurses/include/notcurses/notcurses.h:1073
#6 0x5606f2b9692c in demo_render /home/dank/src/dankamongmen/notcurses/src/demo/hud.c:640
#7 0x5606f2bb8274 in demo_simple_streamer /home/dank/src/dankamongmen/notcurses/src/demo/demo.h:167
#8 0x5606f2bb8274 in streamer /home/dank/src/dankamongmen/notcurses/src/demo/view.c:33
#9 0x7f35f8728ce1 in ffmpeg_stream /home/dank/src/dankamongmen/notcurses/src/media/ffmpeg.c:531
#10 0x7f35f8572e1b in ncvisual_stream /home/dank/src/dankamongmen/notcurses/src/lib/visual.c:69
#11 0x5606f2bb961e in view_video_demo /home/dank/src/dankamongmen/notcurses/src/demo/view.c:56
#12 0x5606f2bb961e in view_demo /home/dank/src/dankamongmen/notcurses/src/demo/view.c:189
#13 0x5606f2b7f20d in ext_demos /home/dank/src/dankamongmen/notcurses/src/demo/demo.c:218
#14 0x5606f2b7f20d in main /home/dank/src/dankamongmen/notcurses/src/demo/demo.c:572
#15 0x7f35f82a47ec in __libc_start_main ../csu/libc-start.c:332
#16 0x5606f2b80d29 in _start (/home/dank/src/dankamongmen/notcurses/build/notcurses-demo+0x1fd29)
0x7f35eaa8a800 is located 16 bytes to the right of 397296-byte region [0x7f35eaa29800,0x7f35eaa8a7f0)
allocated by thread T0 here:
#0 0x7f35f87dcb48 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
#1 0x7f35f8543a9c in engorge_crender_vector /home/dank/src/dankamongmen/notcurses/src/lib/render.c:1552
#2 0x7f35f8543a9c in ncpile_render /home/dank/src/dankamongmen/notcurses/src/lib/render.c:1577
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/dank/src/dankamongmen/notcurses/include/notcurses/notcurses.h:2615 in nccell_fg_alpha
Shadow bytes around the buggy address:
0x0fe73d5494b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fe73d5494c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fe73d5494d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fe73d5494e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fe73d5494f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa
=>0x0fe73d549500:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0fe73d549510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0fe73d549520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0fe73d549530: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0fe73d549540: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0fe73d549550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==1126271==ABORTING |
this reeks of a bad crender reference |
yeah we're passing in const int miny = pile->dimy < nc->lfdimy ? pile->dimy : nc->lfdimy;
const int minx = pile->dimx < nc->lfdimx ? pile->dimx : nc->lfdimx; and that can't be right, was i smoking crack or what |
alright, we're underflowing in
definitely |
there's that one, but there's another type of crash too:
|
so what's going on seems pretty well understood: we're asking so we can obviously check for this, and avoid the bad reference. but that leaves two questions:
i don't like the idea of returning something, because really this is a programming error at a higher level. we call i think resolving that mystery is necessary. let's do that. let's also add a resizecb to the sprixel in |
the other one i'm pretty sure is a miss on |
i'm wondering if we're possibly hitting the wrong
so we come in on y=4, x=0. where the hell are we getting that from? our offsets are (1,48). hrmm is this yes, it is. it's the first one in
very sus! |
so yeah, if |
yeah, we've got a sprixel at offsets 1/290, and we're calling it on 2/131. that's ludicrous. either
|
alright, let's get the pointer we're writing through to in |
checking 0x7f33ceee9020 at absolute coordinates 1/6. ok, we check this all over the place, but normally it's at 1/98:
so we have the same address, but its position seems to have changed. the rvec base didn't change (recently):
so the distance (and true offset) is the same: 0x7f33ceee9020 - 0x7f33ceee6800 = 10272 (0x2820) we think we're at 1/6. 116 + 98 (dimx + offx) == 214 (side question: why 48B? |
Our crender struct was being padded up to 48 bytes. Change the member ordering to get it down to 40 without use of ((packed)) or other alignment-unfriendly methods. Saves 16% of memory devoted to rendering solutions, hopefully with attendant savings in memory traffic. See #2471.
ok well it's definitely |
POSTPAINT BEGINS! 40 0x7f9c42815800 98/400 ok, so there's our problem -- the dimension is unexpectedly changing between |
ahhh, it is happening because this is almost certainly all the cause of the other failure we were seeing. so what to do about this? |
i think we could run |
i can no longer reproduce the failure. looks like that got it =]. |
this is great, I was having unpredictable crashes when resizing while using visuals, but I wanted to create a minimal example before submitting (which I never did). I'll test again soon, hopefully they'll be gone |
To reproduce, keep resizing the terminal window while running the demo.
notcurses 3.0.1 on foot 1.10.3-68-gaeeaf9c0 (Linux 5.11.16-artix1-1)
68 rows (15px) 106 cols (7px) 1020x742 rgb+256 colors
gcc-11.1.0 (LE)
terminfo 6.3.20211021 libdeflate 1.8 GPM n/a
avformat 58.76.100 avutil 56.70.100 swscale 5.9.100 avcodec 58.134.100
The text was updated successfully, but these errors were encountered: