Bug 112869

Summary: grep -iE segfaults using \W unless LANG=C
Product: [Fedora] Fedora Reporter: Davide Bolcioni <davide_bolcioni>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 1CC: twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: athlon   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-01-14 15:49:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Davide Bolcioni 2004-01-04 22:09:03 UTC
Description of problem: Attempting to use grep -iE with \W in the 
pattern segfaults with LANG=it_IT, but not with LANG=C.


Version-Release number of selected component (if applicable): 2.5.1-17.4

How reproducible: Always


Steps to Reproduce:
1. echo '<form>' | LANG=it_IT grep -iE '\Wform\W' segfaults
2.
3.
  
Actual results: segfaults.


Expected results: no segfault and outputs <form>.


Additional info:  echo '<form>' | LANG=C grep -iE '\Wform\W' does not
segfault and works as expected.

Comment 1 Davide Bolcioni 2004-01-04 22:10:18 UTC
If -i is omitted, works as expected.

Comment 2 Tim Waugh 2004-01-05 12:15:13 UTC
This seems to be a glibc bug, as shown by:

#include <locale.h>
#include <regex.h>
#include <ctype.h>
int main (void)
{
  struct re_pattern_buffer re = { 0 };
  unsigned char trans[256];
  int i;
  setlocale (LC_ALL, "en_GB");
  for (i = 0; i < 256; ++i) trans[i] = tolower (i);
  re.translate = trans;
  re_set_syntax (RE_SYNTAX_POSIX_EGREP);
  re_compile_pattern ("\\W", 2, &re);
}

However, I have built grep-2.5.1-24 with a work-around to avoid this bug.

Changing component to glibc and reassigning.

Comment 3 Jakub Jelinek 2004-01-14 15:49:44 UTC
Should be fixed in glibc-2.3.2-101.4.