public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [64-bit]  egrep core dumps when it opens binary files
@ 2013-08-11 22:07 Jim Burwell
  2013-08-12 12:49 ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Burwell @ 2013-08-11 22:07 UTC (permalink / raw)
  To: The Cygwin Mailing List

64 bit egrep gets a segfault and dumps core when it opens binary files:

    {jimb@T510jimb/pty1}~> egrep -vil blarg *
    egrep: archive: Is a directory
    argle
    b.pyc
    bahz
    baktmp
    bargle
    baz
    bbcase
    Segmentation fault (core dumped)

    {jimb@T510jimb/pty1}~> ls -1 * | head -15
    argle
    b.pyc
    bahz
    baktmp
    bargle
    baz
    bbcase
    bigcaps.pcf.gz
    ^^^ dumps when it hits this file

    Core dump file:
    {jimb@T510jimb/pty1}~> cat egrep.exe.stackdump
    Exception: STATUS_ACCESS_VIOLATION at rip=00077C72F7E
    rax=00000006000743BA rbx=00000006000743BA rcx=0000000600090000
    rdx=0000000000000000 rsi=0000000600073F79 rdi=00000000000000E9
    r8 =0000000000000039 r9 =03FFFFFFFFFFF90E r10=000000000000019D
    r11=0000000000000002 r12=000000000022A120 r13=000000060005062C
    r14=0000000000000003 r15=0000000000000000
    rbp=0000000600050976 rsp=000000000022A058
    program=C:\cygwin64\bin\egrep.exe, pid 9056, thread main
    cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
    Stack trace:
    Frame        Function    Args
    00600050976  00077C72F7E (0000022A028, 001801CADC0, 0000022A120,
    006000743BA)
    00600050976  00077B4B6C6 (000000000E9, 00600050976, 0000022A120,
    006000743B9)
    00600050976  001800C4D27 (00000000000, 00000000000, 00000000000,
    0000022A11E)
    00600050976  00100405900 (00000000000, 00600050000, 0000022A128,
    00000010000)
    00600050540  00100404298 (00000000436, 00600050000, 001801130CB,
    00000010000)
    0000022A2F8  0010040277C (0000022A5B0, 000FFFFFFFE, 00000000000,
    00000000002)
    00000000003  00100402E62 (005EE2D8180, 00077BA003C, 00077B05670,
    00000000000)
    0000022A6C0  00100425A9D (7FEFDB6DC4A, 000002AFB40, 00180041C76,
    00000000000)
    0000022AB80  0018004835B (00000000000, 00000000000, 00000000000,
    00000000000)
    00000000000  001800461BB (00000000000, 00000000000, 00000000000,
    00000000000)
    00000000000  0018004637F (00000000000, 00000000000, 00000000000,
    00000000000)
    00000000000  001004243E1 (00000000000, 00000000000, 00000000000,
    00000000000)
    00000000000  00100401010 (00000000000, 00000000000, 00000000000,
    00000000000)
    00000000000  00077B1652D (00000000000, 00000000000, 00000000000,
    00077B99300)
    00000000000  00077C4C521 (00000000000, 00000000000, 00000000000,
    00077B99300)
    End of stack trace


- Jim


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [64-bit]  egrep core dumps when it opens binary files
  2013-08-11 22:07 [64-bit] egrep core dumps when it opens binary files Jim Burwell
@ 2013-08-12 12:49 ` Corinna Vinschen
  2013-08-12 17:41   ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2013-08-12 12:49 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

On Aug 11 15:07, Jim Burwell wrote:
> 64 bit egrep gets a segfault and dumps core when it opens binary files:

Confirmed.  This isn't exactly about binary files, but rather grep
stumbles over Cygwin/Newlib's UTF-16 surrogate pair handling here.

To trigger this problem, three circumstances must conincide:

- you have to use a UTF-8 locale like en_US.UTF-8,
- you have to use grep's -i option,
- and you have to hit a file with a UTF-8 sequence which translates to
  a surrogate.

I'm looking into a patch to handle this uncommon situation and try to
send it upstream.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [64-bit]  egrep core dumps when it opens binary files
  2013-08-12 12:49 ` Corinna Vinschen
@ 2013-08-12 17:41   ` Corinna Vinschen
  2013-08-13 19:39     ` Sylvain Pasche
  0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2013-08-12 17:41 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

On Aug 12 14:49, Corinna Vinschen wrote:
> On Aug 11 15:07, Jim Burwell wrote:
> > 64 bit egrep gets a segfault and dumps core when it opens binary files:
> 
> Confirmed.  This isn't exactly about binary files, but rather grep
> stumbles over Cygwin/Newlib's UTF-16 surrogate pair handling here.
> 
> To trigger this problem, three circumstances must conincide:
> 
> - you have to use a UTF-8 locale like en_US.UTF-8,
> - you have to use grep's -i option,
> - and you have to hit a file with a UTF-8 sequence which translates to
>   a surrogate.
> 
> I'm looking into a patch to handle this uncommon situation and try to
> send it upstream.

I added UTF-16 surrogate handling to the -i option and uploaded a
grep-2.14-2 package to the 64 bit release.  Please give it a tests.
If it works for you, I'll send the patch upstream.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [64-bit]  egrep core dumps when it opens binary files
  2013-08-12 17:41   ` Corinna Vinschen
@ 2013-08-13 19:39     ` Sylvain Pasche
  0 siblings, 0 replies; 6+ messages in thread
From: Sylvain Pasche @ 2013-08-13 19:39 UTC (permalink / raw)
  To: cygwin

On 8/12/2013 7:41 PM, Corinna Vinschen wrote:
>
> I added UTF-16 surrogate handling to the -i option and uploaded a
> grep-2.14-2 package to the 64 bit release.  Please give it a tests.
> If it works for you, I'll send the patch upstream.
>

Hi,

I can confirm it fixes the crash for me. I used this testcase:

echo -n -e '\xf4\x85\x84' > test
grep -i foo test

Which crashed with grep-2.14-1 but not any more with grep-2.14-2.

Sylvain


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [64-bit] egrep core dumps when it opens binary files
  2013-08-14  3:01 Jim Burwell
@ 2013-08-14  7:41 ` Corinna Vinschen
  0 siblings, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2013-08-14  7:41 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 807 bytes --]

On Aug 13 20:01, Jim Burwell wrote:
> > On 8/12/2013 7:41 PM, Corinna Vinschen wrote:
> > >
> > > I added UTF-16 surrogate handling to the -i option and uploaded a
> > > grep-2.14-2 package to the 64 bit release.  Please give it a tests.
> > > If it works for you, I'll send the patch upstream.
> > >
> >
> > Hi,
> >
> > I can confirm it fixes the crash for me. I used this testcase:
> >
> > echo -n -e '\xf4\x85\x84' > test
> > grep -i foo test
> >
> > Which crashed with grep-2.14-1 but not any more with grep-2.14-2.
> >
> > Sylvain
> I can confirm the problem is fixed.  The same test no longer crashes.

Thanks, guys.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [64-bit] egrep core dumps when it opens binary files
@ 2013-08-14  3:01 Jim Burwell
  2013-08-14  7:41 ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Burwell @ 2013-08-14  3:01 UTC (permalink / raw)
  To: The Cygwin Mailing List

> On 8/12/2013 7:41 PM, Corinna Vinschen wrote:
> >
> > I added UTF-16 surrogate handling to the -i option and uploaded a
> > grep-2.14-2 package to the 64 bit release.  Please give it a tests.
> > If it works for you, I'll send the patch upstream.
> >
>
> Hi,
>
> I can confirm it fixes the crash for me. I used this testcase:
>
> echo -n -e '\xf4\x85\x84' > test
> grep -i foo test
>
> Which crashed with grep-2.14-1 but not any more with grep-2.14-2.
>
> Sylvain
I can confirm the problem is fixed.  The same test no longer crashes.


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-14  7:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-11 22:07 [64-bit] egrep core dumps when it opens binary files Jim Burwell
2013-08-12 12:49 ` Corinna Vinschen
2013-08-12 17:41   ` Corinna Vinschen
2013-08-13 19:39     ` Sylvain Pasche
2013-08-14  3:01 Jim Burwell
2013-08-14  7:41 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).