From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26390 invoked by alias); 6 Jul 2007 01:18:22 -0000 Received: (qmail 26370 invoked by uid 48); 6 Jul 2007 01:18:11 -0000 Date: Fri, 06 Jul 2007 01:18:00 -0000 From: "raj dot khem at gmail dot com" To: glibc-bugs@sources.redhat.com Message-ID: <20070706011810.4745.raj.khem@gmail.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/4745] New: Wrong results from scanf with errno set to EINTR X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00022.txt.bz2 Calling scanf with errno set to EINTR produces wrong results with glibc 2.6 Here is a test program. #include #include #include #include #include #include #include #include /*********************************************************************/ int main(int argc, char* argv[]) { printf("setting errno to EINTR\n"); errno = EINTR; printf("checking sscanf\n"); { char str[] = "7-11"; int i, j, n; i = j = n = 0; sscanf(str, " %i - %i %n", &i, &j, &n); printf("found %i-%i (length=%i)\n", i, j, n); assert(i==7); assert(j==11); assert(n==4); } return(0); } How to reproduce gcc test.c -o test Running ./test will now cause an assertion (assert(n==4) at the end of test.c). The output looks like this: ---begin --- setting errno to EINTR checking sscanf found 7-11 (length=0) test: test.c:27: main: Assertion `n==4' failed. Aborted (core dumped) ---end --- In older glibc version 2.2.4 scanf assigns n the correct value of 4. There is patch ( I dont know if this is the right fix) and problem reported against 2.3.2 below http://lists.gnu.org/archive/html/bug-glibc/2003-11/msg00067.html -- Summary: Wrong results from scanf with errno set to EINTR Product: glibc Version: 2.4 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper at redhat dot com ReportedBy: raj dot khem at gmail dot com CC: glibc-bugs at sources dot redhat dot com GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://sourceware.org/bugzilla/show_bug.cgi?id=4745 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.