Bug 499689

Summary: memchr(0,'a',0) evokes segfault
Product: [Fedora] Fedora Reporter: Jim Meyering <meyering>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: bruno, fweimer, jakub
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-05-11 23:38:31 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 Jim Meyering 2009-05-07 17:01:46 UTC
Description of problem: memchr(0, 'a', 0) can evoke a segfault

Version-Release number of selected component (if applicable): glibc-headers-2.9.90-22.x86_64


How reproducible: every time


Steps to Reproduce:

$ cat k.c
#include <string.h>
int main() { return !!(memchr (0, 'a', 0)); }
$ gcc -O k.c; ./a.out
 
Actual results:

Segmentation fault
[Exit 139 (SIGSEGV)]

Expected results:
no segfault

Additional info:

Comment 1 Bruno Haible 2009-05-08 22:19:06 UTC
There is an email thread about this issue starting at
  http://lists.gnu.org/archive/html/bug-gnulib/2009-05/msg00081.html

Comment 2 Bruno Haible 2009-05-11 11:15:17 UTC
A related but different issue is
https://bugzilla.redhat.com/show_bug.cgi?id=500136

Comment 3 Jakub Jelinek 2009-05-11 23:38:31 UTC
This one is undefined behavior, yet works as it used to work again in glibc 2.10.1 in rawhide.

Comment 4 Jim Meyering 2009-05-12 05:55:58 UTC
Thanks.