Bug: bash -e misbehaves with several nested

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Sat Nov 11 18:12:00 GMT 2017


On 2017-11-10 09:42, Pavel Fedin wrote:
>> On Thursday, May 25, 2017 8:47 PM, Brian Inglis wrote:
>> On 2017-05-25 08:40, Andrey Repin wrote:
>>> Greetings, Pavel Fedin!
>>>>>>  Hello! I'd like to report a strange bug in 64-bit bash. The following
script:
>>>>>> ---- cut ---
>>>>>> #/bin/bash -e
>>>>>> DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
>>>>>> echo Works: $DIR
>>>>>> ---- cut ---
>>>>>> Simply exits and produces no output (never reaches echo). The same script
works
>> perfectly
>>>>> on 32 bits. Versions are the same:
>>>>>> --- cut ---
>>>>> It works fine for me.
>>>>> $ ./prova.bash
>>>>> Works: /tmp
>>>>  Huh, works here too, indeed. But there's one little thing. If you just
>>>> copypasted this from my email, then you probably miss "#!"
>>>> (there's just "#", since i retyped the header, and made a typo). And with
>>>> this typo it really works for some reason. Could you make
>>>> sure once again ?
>>>>  Apparently it has to do with -e switch.
>>> I doubt that.
>>>> + cat /home/anrdaemon/Documents/.sh/xx.sh
>>>> #!/bin/bash -xe
>>>> cat "$0"
>>>> DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
>>>> echo Works: $DIR
>>>> +++ dirname /home/anrdaemon/Documents/.sh/xx.sh
>>>> ++ cd /home/anrdaemon/Documents/.sh
>>>> ++ pwd
>>>> + DIR=/home/anrdaemon/Documents/.sh
>>>> + echo Works: /home/anrdaemon/Documents/.sh
>>>> Works: /home/anrdaemon/Documents/.sh
>>> At the same time,
>>>> #/bin/bash -xe
>>>> cat "$0"
>>>> DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
>>>> echo Works: $DIR
>>>> /home/anrdaemon/Documents/.sh/xx.sh: 4:
>>>> /home/anrdaemon/Documents/.sh/xx.sh: Bad substitution
>>>> Works: /home/anrdaemon/Documents/.sh
>>> If you are wondering, what's going on, Â…
>>> sh is not bash. For me. I guess, dash is a little more vocal about
>>> errors, than bash.
>>
>> So the complaint is that sh doesn't work with bash arrays?
>> Hashbangs matter - print that on a T-shirt and sell it ;^>

>  Long time has passed, i've rechecked the problem and it's not gone.
>  This time i've checked it with strace (see long log below). Any hints there?
> --- cut ---
> 
> p.fedin@fedinw7x64 /cygdrive/d/Projects/Test
> $ bash -c ./test.sh
> + DIR=
> 
> p.fedin@fedinw7x64 /cygdrive/d/Projects/Test
> $ strace bash -c ./test.sh

>    65   64249 [main] bash 16056 pinfo_init: Set nice to 0
>    27   64276 [main] bash 16056 pinfo_init: pid 16056, pgid 16056, process_state 0x41
>    13   64289 [main] bash 16056 App version:  2006.1, api: 0.305
>    11   64300 [main] bash 16056 DLL version:  2009.0, api: 0.318
>    11   64311 [main] bash 16056 DLL build:    2017-09-12 10:18
>    48   64359 [main] bash 16056 dtable::extend: size 32, fds 0x1802FA298
>    96   64455 [main] bash 16056 __get_lcid_from_locale: LCID=0x0409
>   243   64698 [main] bash 16056 transport_layer_pipes::connect: Try to connect to named pipe: \\.\pipe\cygwin-e022582115c10879-lpc
>    73   64771 [main] bash 16056 transport_layer_pipes::connect: Error opening the pipe (2)
>    22   64793 [main] bash 16056 client_request::make_request: cygserver un-available
> --- Process 16056 thread 15536 created

> --- Process 16056 thread 20096 created

> --- Process 6596 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000

> --- Process 18176 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000
> --- Process 18176, exception c0000005 at 0000000180128CFA

> --- Process 18176 thread 20260 exited with status 0xc0000005
> --- Process 18176 exited with status 0xc0000005
> 295654  401998 [main] bash 16056 child_info::sync: pid 18176, WFMO returned 1, exit_code 0xC0000005, res 0

> --- Process 10540 thread 13396 created

> --- Process 10540 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000
> --- Process 10540, exception c0000005 at 0000000180128CFA

> --- Process 10540 thread 15880 exited with status 0xc0000005
> --- Process 10540 exited with status 0xc0000005
> 288711 1697816 [main] bash 16056 child_info::sync: pid 10540, WFMO returned 1, exit_code 0xC0000005, res 0

> --- Process 14076 created

> --- Process 14076 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000
> --- Process 14076, exception c0000005 at 0000000180128CFA

> --- Process 14076 thread 6832 exited with status 0xc0000005
> --- Process 14076 exited with status 0xc0000005
> 283609 3986009 [main] bash 16056 child_info::sync: pid 14076, WFMO returned 1, exit_code 0xC0000005, res 0

> --- Process 14972 created

> --- Process 14972 thread 6736 created

> --- Process 14972 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000
> --- Process 14972, exception c0000005 at 0000000180128CFA

> --- Process 14972 thread 10732 exited with status 0xc0000005
> --- Process 14972 exited with status 0xc0000005
> 280402 8271824 [main] bash 16056 child_info::sync: pid 14972, WFMO returned 1, exit_code 0xC0000005, res 0

> --- Process 13904 created

> --- Process 13904 thread 20164 created

> --- Process 13904 loaded C:\PaperSecu\paperhk64.dll at 000007FEF5340000
> --- Process 13904, exception c0000005 at 0000000180128CFA

> --- Process 13904 thread 16364 exited with status 0xc0000005
> --- Process 13904 exited with status 0xc0000005
> 305424 16581402 [main] bash 16056 child_info::sync: pid 13904, WFMO returned 1, exit_code 0xC0000005, res 0

> --- Process 6596 thread 18852 exited with status 0xfe
> --- Process 6596 thread 16828 exited with status 0xfe
> --- Process 6596 thread 14384 exited with status 0xfe
> --- Process 6596 exited with status 0xfe
> 16592108 17071702 [waitproc] bash 16056! pinfo::maybe_set_exit_code_from_windows: pid 16056, exit value - old 0x800FE00, windows 0xDEADBEEF, cygwin 0x800FE00
>    50 17071752 [waitproc] bash 16056! proc_waiter: exiting wait thread for pid 16056
>    17 17071769 [main] bash 16056! proc_terminate: nprocs 1
>    35 17071804 [main] bash 16056! proc_subproc: args: 5, 1
>    32 17071836 [main] bash 16056! proc_subproc: clear waiting threads
>    14 17071850 [main] bash 16056! proc_subproc: finished clearing
>    18 17071868 [main] bash 16056! proc_subproc: returning 1
>    17 17071885 [main] bash 16056! cygthread::terminate_thread: thread '(null)', id 0x310C, inuse 0, stack_ptr 0x30DCCD0
>    14 17071899 [main] bash 16056! proc_terminate: leaving
>    14 17071913 [main] bash 16056! pinfo::maybe_set_exit_code_from_windows: pid 16056, exit value - old 0x800FE00, windows 0xDEADBEEF, cygwin 0x800FE00
>    22 17071935 [main] bash 16056! pinfo::exit: Calling ExitProcess n 0x4000000, exitcode 0xFE
> --- Process 16056 thread 18444 exited with status 0xfe
> --- Process 16056 thread 8660 exited with status 0xfe
> --- Process 16056 thread 15536 exited with status 0xfe
> --- Process 16056 thread 12556 exited with status 0xfe
> --- Process 16056 thread 13992 exited with status 0xfe
> --- Process 16056 exited with status 0xfe
> 
> p.fedin@fedinw7x64 /cygdrive/d/Projects/Test
> $

SIGSEGV after loading paperhk64.dll suggests that SecuPrint is probably BLODA
(Big List Of Dodgy Apps), many of which are meant to have something to do with
security, but are so badly written that they crash other apps, and probably
contain and create security exploit opportunities.

Uninstall it, or delete paperhk64.dll and maybe that whole folder, file a vendor
bug report, and complain thru channels that it crashes your tools, which have
nothing to do with printing, and interferes with you getting your work done.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list