Mon 23 Nov 2015 04:53:29 PM UTC, original submission:
A bug in docker has uncovered what I consider to be a bug in make. If you run make inside an exec'd shell (docker exec -ti "testmake" /bin/bash) it will SEGV because isatty(fileno(stdout)) returns 1 but ttyname(fileno(stdout)) returns NULL.
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00007ffff789982e in __GI___strdup (s=0x0) at strdup.c:41
#2 0x0000000000417b19 in xstrdup (ptr=ptr@entry=0x0) at /root/workspace/dev_tools/stage1/source/make-4.1/misc.c:259
#3 0x000000000042274c in define_variable_in_set (name=name@entry=0x428dcb "MAKE_TERMOUT", length=length@entry=12, value=0x0,
origin=origin@entry=o_default, recursive=recursive@entry=0, set=set@entry=0x634040 <global_variable_set>, flocp=flocp@entry=0x0)
at /root/workspace/dev_tools/stage1/source/make-4.1/variable.c:243
#4 0x0000000000406ac0 in main (argc=<optimized out>, argv=<optimized out>, envp=0x7fffffffe718)
at /root/workspace/dev_tools/stage1/source/make-4.1/main.c:1404
The following code in main.c should check the return value of TTYNAME (which according to man pages can return NULL as an exception condition) instead of blindly passing the pointer:
main.c:1401
#ifdef HAVE_ISATTY
if (isatty (fileno (stdout)))
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
o_default, 0)->export = v_export;
if (isatty (fileno (stderr)))
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
o_default, 0)->export = v_export;
#endif
|