dankamongmen / growlight

notcurses block device manager / system installation tool
https://nick-black.com/dankwiki/index.php/Growlight
GNU General Public License v3.0
85 stars 12 forks source link

blowup in draw routine using notcurses 1.7.5 #86

Closed dankamongmen closed 3 years ago

dankamongmen commented 3 years ago

Using the notcurses 1.7.5 prebuild, and a window of size 80x45, I see a coredump in growlight on schwarzgerat shortly after startup:

==1213284== Thread 27:
==1213284== Invalid read of size 8
==1213284==    at 0x12AA5E: device_lines (notcurses.c:735)
==1213284==    by 0x12AA5E: device_lines (notcurses.c:731)
==1213284==    by 0x12AA5E: print_adapter_devs (notcurses.c:1481)
==1213284==    by 0x12AA5E: redraw_adapter (notcurses.c:1521)
==1213284==    by 0x4D03B8B: ncreel_draw_tablet (reel.c:289)
==1213284==    by 0x4D03E81: draw_following_tablets (reel.c:339)
==1213284==    by 0x4D04010: ncreel_redraw (reel.c:668)
==1213284==    by 0x4D0453D: ncreel_add (reel.c:786)
==1213284==    by 0x12794A: adapter_callback (notcurses.c:5575)
==1213284==    by 0x127BA1: block_callback (notcurses.c:5741)
==1213284==    by 0x11747F: rescan (growlight.c:1136)
==1213284==    by 0x118440: create_new_device_inner (growlight.c:1154)
==1213284==    by 0x118440: create_new_device (growlight.c:1196)
==1213284==    by 0x1167F4: lookup_device (growlight.c:1266)
==1213284==    by 0x1188E5: scan_device (growlight.c:1398)
==1213284==    by 0x4D21EA6: start_thread (pthread_create.c:477)
==1213284==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==1213284== 
==1213284== 
==1213284== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==1213284==    at 0x4D2CFBF: raise (raise.c:46)
==1213284==    by 0x4D2D13F: ??? (in /lib/x86_64-linux-gnu/libpthread-2.31.so)
==1213284==    by 0x12AA5D: device_lines (notcurses.c:734)
==1213284==    by 0x12AA5D: print_adapter_devs (notcurses.c:1481)
==1213284==    by 0x12AA5D: redraw_adapter (notcurses.c:1521)
==1213284==    by 0x4D03B8B: ncreel_draw_tablet (reel.c:289)
==1213284==    by 0x4D03E81: draw_following_tablets (reel.c:339)
==1213284==    by 0x4D04010: ncreel_redraw (reel.c:668)
==1213284==    by 0x4D0453D: ncreel_add (reel.c:786)
==1213284==    by 0x12794A: adapter_callback (notcurses.c:5575)
==1213284==    by 0x127BA1: block_callback (notcurses.c:5741)
==1213284==    by 0x11747F: rescan (growlight.c:1136)
==1213284==    by 0x118440: create_new_device_inner (growlight.c:1154)
==1213284==    by 0x118440: create_new_device (growlight.c:1196)
==1213284==    by 0x1167F4: lookup_device (growlight.c:1266)
==1213284== 
==1213284== HEAP SUMMARY:
==1213284==     in use at exit: 6,662,696 bytes in 12,504 blocks
==1213284==   total heap usage: 1,652,490 allocs, 1,639,986 frees, 1,535,426,777 bytes allocated
==1213284== 
==1213284== LEAK SUMMARY:
==1213284==    definitely lost: 1,232 bytes in 2 blocks
==1213284==    indirectly lost: 20,040 bytes in 255 blocks
==1213284==      possibly lost: 5,167,985 bytes in 570 blocks
==1213284==    still reachable: 1,473,439 bytes in 11,677 blocks
==1213284==         suppressed: 0 bytes in 0 blocks
==1213284== Rerun with --leak-check=full to see details of leaked memory
==1213284== 
==1213284== For lists of detected and suppressed errors, rerun with: -s
==1213284== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
[schwarzgerat](0) $ 
dankamongmen commented 3 years ago
Thread 1 (Thread 0x7f3d99ffb700 (LWP 1439142)):
#0  device_lines (expa=<optimized out>, bo=<optimized out>) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:743
#1  device_lines (bo=<optimized out>, expa=<optimized out>) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:731
#2  print_adapter_devs (drawfromtop=true, as=0x7f3d50004360, n=0x7f3d50003510) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:1484
#3  redraw_adapter (t=<optimized out>, drawfromtop=<optimized out>) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:1523
#4  0x00007f3db762eb8c in ncreel_draw_tablet (nr=nr@entry=0x5583af5ca400, t=t@entry=0x7f3d50001990, frontiertop=<optimized out>, frontiertop@entry=-2, frontierbottom=<optimized out>, direction=direction@entry=DIRECTION_DOWN) at /home/dank/src/dankamongmen/notcurses/src/lib/reel.c:289
#5  0x00007f3db762ee82 in draw_following_tablets (nr=nr@entry=0x5583af5ca400, otherend=0x7f3d50001990, frontiertop=-2, frontierbottom=frontierbottom@entry=0x7f3d99ff5b04) at /home/dank/src/dankamongmen/notcurses/src/lib/reel.c:339
#6  0x00007f3db762f011 in ncreel_redraw (nr=nr@entry=0x5583af5ca400) at /home/dank/src/dankamongmen/notcurses/src/lib/reel.c:668
#7  0x00007f3db762f53e in ncreel_add (nr=0x5583af5ca400, after=0x0, before=0x5583af5e87f0, cbfxn=0x5583aea951b0 <redraw_adapter>, opaque=0x7f3d50004360) at /home/dank/src/dankamongmen/notcurses/src/lib/reel.c:786
#8  0x00005583aea9297b in adapter_callback (a=0x7f3d84001ee0, state=0x7f3d50004360) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:5576
#9  0x00005583aea92bd2 in block_callback (d=0x7f3d50000ba0, v=0x0) at /home/dank/src/dankamongmen/growlight/src/notcurses/notcurses.c:5742
#10 0x00005583aea82410 in rescan (name=name@entry=0x5583af655520 "sr0", d=d@entry=0x7f3d50000ba0) at /home/dank/src/dankamongmen/growlight/src/growlight.c:1136
#11 0x00005583aea833d1 in create_new_device_inner (name=0x5583af655520 "sr0") at /home/dank/src/dankamongmen/growlight/src/growlight.c:1154
#12 create_new_device (name=name@entry=0x5583af655520 "sr0") at /home/dank/src/dankamongmen/growlight/src/growlight.c:1196
#13 0x00005583aea81785 in lookup_device (name=name@entry=0x5583af655520 "sr0") at /home/dank/src/dankamongmen/growlight/src/growlight.c:1266
#14 0x00005583aea83876 in scan_device (name=0x5583af655520) at /home/dank/src/dankamongmen/growlight/src/growlight.c:1398
#15 0x00007f3db75eeea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x00007f3db751eeaf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
dankamongmen commented 3 years ago

Ahh, needed to check cur for NULL while iterating through print_adapter_devs(). Fixed!