{"thread":{"id":"32350","subject":"[PATCH 0/1] cygwin test failures due to printf","startedAt":"2012-12-15T19:08:42Z","lastAt":"2012-12-15T19:08:42Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"204937","messageId":"50CCCABA.40406@ramsay1.demon.co.uk","threadId":"32350","inReplyTo":null,"subject":"[PATCH 0/1] cygwin test failures due to printf","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-12-15T19:08:42Z","receivedAt":"2012-12-15T19:08:42Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nHi Junio,\n\nSorry for being a bit tardy on this; I noticed these test failures\non cygwin close to the start of this cycle, just before I went\ninto hospital, but have only just got around to looking into it...\n\nIn particular, the following tests fail: t0021, t0030, t1410, t3032,\nt3304, t3404 and t4132. [The list of failing tests is not actually\nall that interesting, because the fault is not actually with the\ntests!]\n\nThese failures are provoked by commit 7bc0911d (\"test-lib: Fix say_color ()\nnot to interpret \\a\\b\\c in the message\", 11-10-2012).\n\nIf we look at t0021 as a representative, then:\n\n    $ ./t0021-conversion.sh\n    ok 1 - setup\n    ok 2 - check\n    ok 3 - expanded_in_repo\n          5 [sig] sh 2388 C:\\cygwin\\bin\\sh.exe: *** fatal error - called with threadlist_ix -1\n    ./test-lib.sh: line 207:  2388 Hangup                  \\\n        ( TERM=$ORIGINAL_TERM; export TERM; case \"$1\" in\n        error)\n            tput bold; tput setaf 1\n        ;;\n        skip)\n            tput bold; tput setaf 4\n        ;;\n        warn)\n            tput bold; tput setaf 3\n        ;;\n        pass)\n            tput setaf 2\n        ;;\n        info)\n            tput setaf 3\n        ;;\n        *)\n            test -n \"$quiet\" && return\n        ;;\n    esac; shift; printf \"%s\" \"$*\"; tput sgr0; echo )\n    ok 4 - filter shell-escaped filenames\n    ok 5 - required filter success\n    ok 6 - required filter smudge failure\n    ok 7 - required filter clean failure\n    # passed all 7 test(s)\n    1..7\n    $ \n\nWe see that the \"--color\" version of say_color(), despite the bash builtin\nprintf function crashing the shell (sh.exe is actually bash for me), passes\njust fine. Note that the message passed to say_color() is printed before\nthe shell is aborted (via SIGHUP), but that the \"tput sgr0; echo\" has been\nskipped. This results in the occasional line of output in the wrong colour.\n\nThis has been happening for several years and, given that there are no\nadverse consequences (ignoring the additional error message spew), I have\nbeen happy to ignore this problem. :D\n\nNote that the \"--no-color\" version of say_color() did not have this problem\nsince it used echo, rather than printf, until commit 7bc0911d ... \n\n    $ ./t0021-conversion.sh --no-color\n    ok 1 - setup\n    ok 2 - check\n    ok 3 - expanded_in_repo\n          6 [sig] sh 2740 C:\\cygwin\\bin\\sh.exe: *** fatal error - called with threadlist_ix -1\n    Hangup\n    $ \n\nNote that, unlike the \"--color\" version of say_color(), the printf call is\nnot contained within a sub-shell. Indeed, a simple solution to this problem\nwould be to execute the body of the function from within a \"(...)\" sub-shell.\nThis actually works, since the extra error message spew does not cause a\nTAP syntax error to confuse 'prove'. However, I would never suggest this\nas a solution, given that it already takes over 3 hours to run the tests...\n\nAlso, note that another solution is to call the external version of printf\n(e.g. via /usr/bin/printf) but, again, I would not suggest adding to the\nfork-exec load by replacing a call to a shell builtin with an external\nprogram...\n\nNote that:\n\n    $ cygcheck /bin/sh.exe\n    C:/cygwin/bin/sh.exe\n      C:/cygwin/bin\\cygwin1.dll\n        C:\\WINDOWS\\system32\\ADVAPI32.DLL\n          C:\\WINDOWS\\system32\\KERNEL32.dll\n            C:\\WINDOWS\\system32\\ntdll.dll\n          C:\\WINDOWS\\system32\\RPCRT4.dll\n            C:\\WINDOWS\\system32\\Secur32.dll\n      C:/cygwin/bin\\cygintl-8.dll\n        C:/cygwin/bin\\cygiconv-2.dll\n      C:/cygwin/bin\\cygreadline6.dll\n        C:/cygwin/bin\\cygncurses-8.dll\n        C:\\WINDOWS\\system32\\USER32.dll\n          C:\\WINDOWS\\system32\\GDI32.dll\n    $ \n\n    $ strings /bin/cygwin1.dll | grep 'called with'\n    called with threadlist_ix %d\n    called with invalid value %d\n    openlog called with (%s, %d, %d)\n    $\n\nSo, the error message is coming from the cygwin dll (no surprise there).\nI have a fairly recent source snapshot of cygwin, but this message or the\ncode that uses it is not present. In order to debug this further, I would\nneed to find the source code for the version I am using (1.5.22). This does\nnot excite me too much. ;-)\n\nAs a simpler solution, the patch which follows allows me to customize\nthe function used to do the output. This allows me to revert to using\necho and, as a bonus, fixes the \"--color\" version of say_color() at the\nsame time.\n\nI admit that I find this solution a bit ugly, but it has (at least) two\nvirtues:\n   1. it works!\n   2. it's not as ugly as some other solutions I had tried. :-P\n\nATB,\nRamsay Jones\n"}]}