Segfault using `watch -c` with ANSI escapes in output

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Segfault using `watch -c` with ANSI escapes in output

Adam Dinwoodie-2
I'm seeing a segfault from using `watch -c` with commands that output
ANSI colour sequences, which is a bit sad given the whole point of the
`-c` is to get the ANSI colour sequences to be displayed.

Simple test case:

    $ echo -e '\e[0;32mGreen\e[0;0m' >escapes

    $ cat escapes  # Text is green in my terminal
    Green

    $ xxd escapes
    00000000: 1b5b 303b 3332 6d47 7265 656e 1b5b 303b  .[0;32mGreen.[0;
    00000010: 306d 0a                                  0m.

    $ watch -c cat escapes
    Segmentation fault (core dumped)

    $ cat watch.exe.stackdump
    Exception: STATUS_ACCESS_VIOLATION at rip=001004029B0
    rax=0000000058F5FF8D rbx=0000000600001200 rcx=0000000600000060
    rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000004
    r8 =00000000FFFFCA2C r9 =000000018013C800 r10=0000000100000000
    r11=000000010040299A r12=0000000000000004 r13=00000000FFFFCAF0
    r14=0000000600000E50 r15=00000001801F82C0
    rbp=0000000000000000 rsp=00000000FFFFCA60
    program=C:\cygwin64\bin\watch.exe, pid 12100, thread main
    cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
    Stack trace:
    Frame        Function    Args
    00000000000  001004029B0 (00000000000, 00000000000, 00000000030,
30001010000FF00)
    000FFFFCCC0  00180047812 (00000000000, 00000000000, 00000000000,
00000000000)
    00000000000  001800455E3 (00000000000, 00000000000, 00000000000,
00000000000)
    000FFFFFFF0  00180045694 (00000000000, 00000000000, 00000000000,
00000000000)
    End of stack trace

This works as expected when using `watch` without the `-c` option, and
when using `watch -c` with output that doesn't include any ANSI colour
sequences.

Output from `cygcheck -srv` is attached, and `cygcheck -f
/usr/bin/watch.exe` returns `procps-ng-3.3.11-1`.


--
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

cygcheck.out (99K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Segfault using `watch -c` with ANSI escapes in output

Brian Inglis
On 2017-04-18 06:36, Adam Dinwoodie wrote:

> I'm seeing a segfault from using `watch -c` with commands that output
> ANSI colour sequences, which is a bit sad given the whole point of the
> `-c` is to get the ANSI colour sequences to be displayed.
> Simple test case:
>     $ echo -e '\e[0;32mGreen\e[0;0m' >escapes
>     $ cat escapes  # Text is green in my terminal
>     Green
>     $ xxd escapes
>     00000000: 1b5b 303b 3332 6d47 7265 656e 1b5b 303b  .[0;32mGreen.[0;
>     00000010: 306d 0a                                  0m.
>     $ watch -c cat escapes
>     Segmentation fault (core dumped)

Dies on me too:
$ uname -srvmo
CYGWIN_NT-10.0 2.8.0(0.309/5/3) 2017-04-01 20:47 x86_64 Cygwin
$ watch --version
watch from procps-ng 3.3.11

gdb crashes with dumper .core.

$ gdb watch
...
Reading symbols from watch...(no debugging symbols found)...done.
(gdb) run -c cat e
Starting program: /usr/bin/watch -c cat e
[New Thread 436.0x19dc]
[New Thread 436.0x1e44]
[New Thread 436.0x834]
[New Thread 436.0x12d0]
[New Thread 436.0x1508]
[New Thread 436.0xa24]

Program received signal SIGSEGV, Segmentation fault.
0x00000001004029b0 in ?? ()
(gdb) bt
#0  0x00000001004029b0 in ?? ()
#1  0x0000000180047812 in _cygwin_exit_return () at /usr/src/debug/cygwin-2.8.0-1/winsup/cygwin/dcrt0.cc:1018
#2  0x00000001800455e3 in _cygtls::call2 (this=0xffffce00, func=0x1800468d0 <dll_crt0_1(void*)>, arg=0x0,
    buf=buf@entry=0xffffcdf0) at /usr/src/debug/cygwin-2.8.0-1/winsup/cygwin/cygtls.cc:40
#3  0x0000000180045694 in _cygtls::call (func=<optimized out>, arg=<optimized out>)
    at /usr/src/debug/cygwin-2.8.0-1/winsup/cygwin/cygtls.cc:27
#4  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) q
A debugging session is active.

        Inferior 1 [process 436] will be killed.

Quit anyway? (y or n) y

> This works as expected when using `watch` without the `-c` option, and
> when using `watch -c` with output that doesn't include any ANSI colour
> sequences.

Same here e.g. $ watch cat e; watch -c cat -A e both work okay.

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Segfault using `watch -c` with ANSI escapes in output

Duncan Roe-2
In reply to this post by Adam Dinwoodie-2
On Tue, Apr 18, 2017 at 01:36:34PM +0100, Adam Dinwoodie wrote:

> I'm seeing a segfault from using `watch -c` with commands that output
> ANSI colour sequences, which is a bit sad given the whole point of the
> `-c` is to get the ANSI colour sequences to be displayed.
>
> Simple test case:
>
>     $ echo -e '\e[0;32mGreen\e[0;0m' >escapes
>
>     $ cat escapes  # Text is green in my terminal
>     Green
>
>     $ xxd escapes
>     00000000: 1b5b 303b 3332 6d47 7265 656e 1b5b 303b  .[0;32mGreen.[0;
>     00000010: 306d 0a                                  0m.
>
>     $ watch -c cat escapes
>     Segmentation fault (core dumped)
>
>     $ cat watch.exe.stackdump
>     Exception: STATUS_ACCESS_VIOLATION at rip=001004029B0
>     rax=0000000058F5FF8D rbx=0000000600001200 rcx=0000000600000060
>     rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000004
>     r8 =00000000FFFFCA2C r9 =000000018013C800 r10=0000000100000000
>     r11=000000010040299A r12=0000000000000004 r13=00000000FFFFCAF0
>     r14=0000000600000E50 r15=00000001801F82C0
>     rbp=0000000000000000 rsp=00000000FFFFCA60
>     program=C:\cygwin64\bin\watch.exe, pid 12100, thread main
>     cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
>     Stack trace:
>     Frame        Function    Args
>     00000000000  001004029B0 (00000000000, 00000000000, 00000000030,
> 30001010000FF00)
>     000FFFFCCC0  00180047812 (00000000000, 00000000000, 00000000000,
> 00000000000)
>     00000000000  001800455E3 (00000000000, 00000000000, 00000000000,
> 00000000000)
>     000FFFFFFF0  00180045694 (00000000000, 00000000000, 00000000000,
> 00000000000)
>     End of stack trace
>
> This works as expected when using `watch` without the `-c` option, and
> when using `watch -c` with output that doesn't include any ANSI colour
> sequences.
>
> Output from `cygcheck -srv` is attached, and `cygcheck -f
> /usr/bin/watch.exe` returns `procps-ng-3.3.11-1`.


Where does "watch" come from? It's not on my cygwin installation:

> 16:12:50$ type watch
> -bash: type: watch: not found

and when I enter "watch" in the installer Search window, all it shows me is

> xfce-mailwatch-plugin: Xfce mail watcher panel plugin
and
> xfce-mailwatch-plugin-debuginfo: Debug info for xfce4-mailwatch-plugin

Cheers ... Duncan.

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Segfault using `watch -c` with ANSI escapes in output

Csaba Raduly-2
On Wed, Apr 19, 2017 at 8:35 AM, Duncan Roe wrote:
>
> Where does "watch" come from? It's not on my cygwin installation:
>
>> 16:12:50$ type watch
>> -bash: type: watch: not found
>

https://cygwin.com/cgi-bin2/package-grep.cgi?grep=watch%5C.exe&arch=x86_64

gives us

https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86_64%2Fprocps%2Fprocps-3.2.8-5&grep=watch%5C.exe

Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Segfault using `watch -c` with ANSI escapes in output

Jon TURNEY
In reply to this post by Brian Inglis
On 18/04/2017 16:10, Brian Inglis wrote:

> On 2017-04-18 06:36, Adam Dinwoodie wrote:
>> I'm seeing a segfault from using `watch -c` with commands that output
>> ANSI colour sequences, which is a bit sad given the whole point of the
>> `-c` is to get the ANSI colour sequences to be displayed.
>> Simple test case:
>>     $ echo -e '\e[0;32mGreen\e[0;0m' >escapes
>>     $ cat escapes  # Text is green in my terminal
>>     Green
>>     $ xxd escapes
>>     00000000: 1b5b 303b 3332 6d47 7265 656e 1b5b 303b  .[0;32mGreen.[0;
>>     00000010: 306d 0a                                  0m.
>>     $ watch -c cat escapes
>>     Segmentation fault (core dumped)
>
> Dies on me too:
> $ uname -srvmo
> CYGWIN_NT-10.0 2.8.0(0.309/5/3) 2017-04-01 20:47 x86_64 Cygwin
> $ watch --version
> watch from procps-ng 3.3.11
>
> gdb crashes with dumper .core.
>
> $ gdb watch
> ...
> Reading symbols from watch...(no debugging symbols found)...done.

If you install procps-ng-debuginfo for symbols...

> (gdb) run -c cat e
> Starting program: /usr/bin/watch -c cat e
> [New Thread 436.0x19dc]
> [New Thread 436.0x1e44]
> [New Thread 436.0x834]
> [New Thread 436.0x12d0]
> [New Thread 436.0x1508]
> [New Thread 436.0xa24]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000001004029b0 in ?? ()
> (gdb) bt
> #0  0x00000001004029b0 in ?? ()

... you'll see the obvious mistake which has been fixed upstream for a
while [1].

[1] https://gitlab.com/procps-ng/procps/issues/11


--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Segfault using `watch -c` with ANSI escapes in output

Duncan Roe-2
In reply to this post by Csaba Raduly-2
On Wed, Apr 19, 2017 at 11:14:02AM +0200, Csaba Raduly wrote:

> On Wed, Apr 19, 2017 at 8:35 AM, Duncan Roe wrote:
> >
> > Where does "watch" come from? It's not on my cygwin installation:
> >
> >> 16:12:50$ type watch
> >> -bash: type: watch: not found
> >
>
> https://cygwin.com/cgi-bin2/package-grep.cgi?grep=watch%5C.exe&arch=x86_64
>
> gives us
>
> https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86_64%2Fprocps%2Fprocps-3.2.8-5&grep=watch%5C.exe
>
> Csaba

Thanks Csaba - got it. Is now version 3.3.11 (according to spinner), or 3.3.10
(according to watch). Either way, it now works fine,

Cheers ... Duncan.

--
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

Loading...