dankamongmen / growlight

notcurses block device manager / system installation tool

Home Page:https://nick-black.com/dankwiki/index.php/Growlight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

segfault in debian autopkgtests arising from redirected output

dankamongmen opened this issue · comments

run e.g. echo blockdev -v | growlight --notroot > /dev/null and watch it segfault. this is killing us on the debian autopkgtests: https://ci.debian.net/data/autopkgtest/unstable/ppc64el/g/growlight/15920122/log.gz

Couldn't read link at /sys/class/block/debcargo-unstable-amd64-sbuild (No such file or directory)
==1732880== Invalid read of size 2
==1732880==    at 0x4D40EF1: ncdirect_readline (in /usr/lib/x86_64-linux-gnu/libnotcurses-core.so.2.4.5)
==1732880==    by 0x10FF1A: tty_ui (readline.c:2063)
==1732880==    by 0x10FF1A: main (readline.c:2181)
==1732880==  Address 0x452 is not stack'd, malloc'd or (recently) free'd
==1732880== 
==1732880== 
==1735245== Invalid read of size 2
==1735245==    at 0x4D40EF1: UnknownInlinedFun (termdesc.h:204)
==1735245==    by 0x4D40EF1: ncdirect_readline (direct.c:966)
==1735245==    by 0x10FF1A: tty_ui (readline.c:2063)
==1735245==    by 0x10FF1A: main (readline.c:2181)
==1735245==  Address 0x452 is not stack'd, malloc'd or (recently) free'd
==1735245== 
==1735245== 

note that the readline PoC run out of Notcurses does not crash in this manner.

==1740495== Invalid read of size 2
==1740495==    at 0x4D40461: get_escape (termdesc.h:210)
==1740495==    by 0x4D40461: ncdirect_readline (direct.c:973)
==1740495==    by 0x10FF1A: tty_ui (readline.c:2063)
==1740495==    by 0x10FF1A: main (readline.c:2181)
==1740495==  Address 0x452 is not stack'd, malloc'd or (recently) free'd
==1740495== 
==1740495== 
==1740495== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==1740495==  Access not within mapped region at address 0x452
==1740495==    at 0x4D40461: get_escape (termdesc.h:210)
==1740495==    by 0x4D40461: ncdirect_readline (direct.c:973)
==1740495==    by 0x10FF1A: tty_ui (readline.c:2063)
==1740495==    by 0x10FF1A: main (readline.c:2181)
==1740495==  If you believe this happened as a result of a stack
==1740495==  overflow in your program's main thread (unlikely but
==1740495==  possible), you can try to increase the size of the
==1740495==  main thread stack using the --main-stacksize= flag.
==1740495==  The main thread stack size used in this run was 8388608.
==1740495== 

it looks like we've got a NULL ncdirect? well that'll definitely do it.

cool got it. we should just always be creating an ncdirect, even if not connected to a terminal. after all, it doesn't require a terminal.