grep aborts when using perl regexps on some binary file

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 6.6

Issue

  • When running:
"grep -qP "[\x80-\xFF]" config_21.SYB031.QUAD0009.FILTER.dat.nascii"

Output is:
Aborted (core dumped)
You have mail in /var/spool/mail/root

Resolution

Root Cause

  • The problem happens because grep-2.6.3 in rhel6 will abort if pcre_exec returns <=0 and a value other than PCRE_ERROR_NOMATCH or PCRE_ERROR_NOMEMORY.

Diagnostic Steps

  • bt pattern

Core was generated by `grep -P Warning server.20160224.000000.log.gz server.20160301.000000.log.gz ser'. Program terminated with signal 6, Aborted. #0 0x000000347c032625 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); (gdb) bt #0 0x000000347c032625 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x000000347c033e05 in abort () at abort.c:92 #2 0x0000000000403855 in Pexecute (buf=0x158d000 "\037\213\b\b\303\022\314V", size=<value optimized out>, match_size=0x7fff01e12510, start_ptr=0x0) at pcresearch.c:160 #3 0x0000000000405211 in do_execute (beg=<value optimized out>, lim=0x1590e95 "\360\017\225\203\251\304_8Y\261zVG@\177\356\257?&4x\206\267\321\b~\324ǹY\360\275=\372D\373\354ձA\275\243\021\066\203\214\204\177\357'\377\367^\334r{\273\067G\276\024\036\321kd\275\362%\227(^\230\251\320H#^\273 ^j,^\322\356\230/]A\371\222\032\371\332~\371\322:\032\227/5\177\260\343k\345\253\064\361\"*̎0\336F\274\026\210\227\"i\212\256U*^:s\177!44\326l\276\214\022\305ː\025\030o#^\333f\275\376\006=\021\067`P\246\002") at main.c:973 #4 grepbuf (beg=<value optimized out>, lim=0x1590e95 "\360\017\225\203\251\304_8Y\261zVG@\177\356\257?&4x\206\267\321\b~\324ǹY\360\275=\372D\373\354ձA\275\243\021\066\203\214\204\177\357'\377\367^\334r{\273\067G\276\024\036\321kd\275\362%\227(^\230\251\320H#^\273 ^j,^\322\356\230/]A\371\222\032\371\332~\371\322:\032\227/5\177\260\343k\345\253\064\361\"*̎0\336F\274\026\210\227\"i\212\256U*^:s\177!44\326l\276\214\022\305ː\025\030o#^\333f\275\376\006=\021\067`P\246\002") at main.c:1008 #5 0x00000000004059f1 in grep (file=0x7fff01e13954 "server.20160224.000000.log.gz", stats=0x619a40) at main.c:1128 #6 grepfile (file=0x7fff01e13954 "server.20160224.000000.log.gz", stats=0x619a40) at main.c:1258 #7 0x0000000000405fe9 in main (argc=<value optimized out>, argv=<value optimized out>) at main.c:2187

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.