NetBSD Problem Report #39347
From kretschm@cs.uni-bonn.de Wed Aug 13 08:08:24 2008
Return-Path: <kretschm@cs.uni-bonn.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 64FB963B11D
for <gnats-bugs@gnats.NetBSD.org>; Wed, 13 Aug 2008 08:08:24 +0000 (UTC)
Message-Id: <1218614899.041823.12497.nullmailer@tiger.cs.uni-bonn.de>
Date: Wed, 13 Aug 2008 10:08:19 +0200
From: kretschm@cs.uni-bonn.de
Reply-To: kretschm@cs.uni-bonn.de
To: gnats-bugs@gnats.NetBSD.org
Subject: *wscanf bug
X-Send-Pr-Version: 3.95
>Number: 39347
>Category: lib
>Synopsis: *wscanf bug
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 13 08:10:00 +0000 2008
>Closed-Date: Sat Dec 19 02:37:39 +0000 2015
>Last-Modified: Sat Dec 19 02:37:39 +0000 2015
>Originator: Matthias Kretschmer
>Release: NetBSD 4.0
>Organization:
Private
>Environment:
System: NetBSD tiger 4.0 NetBSD 4.0 (GENERIC) #1: Thu Dec 27 15:39:36 CET 2007 ignatios@random85.cs.uni-bonn.de:/var/itch/sources/4.0/oi/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
swscanf() produces core dumps on i386. wscanf() returns bad results.
swscanf() doesn't core dump on amd64.
The following two pieces of code demonstrate the problem:
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
int
main(int argc, char **argv)
{
int level;
if (setlocale(LC_ALL, "") == NULL)
printf("foo\n");
swscanf(L"% new section: 10\n", L"%% new section: %d\n", &level);
printf("%d\n", level);
return 0;
}
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
int main(void)
{
int i;
float fp;
char c,s[81];
if (setlocale(LC_CTYPE, "") == NULL) {
fprintf(stderr, "can't set locale\n");
exit(1);
}
printf("Enter an integer, a real number, a character and a string : \n");
if (wscanf(L"%d %f %c %s", &i, &fp,&c, s) != 4)
printf("Some fields were not assigned\n");
else {
printf("integer = %d\n", i);
printf("real number = %f\n", fp);
printf("character = %c\n", c);
printf("string = %s\n", s);
}
return 0;
}
The second test application returns wrong results on NetBSD/amd64 and
NetBSD/i386. The first test application core dumps on NetBSD/i386.
>How-To-Repeat:
Just run the code above.
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->lib-bug-people
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Sat, 08 Nov 2008 06:52:39 +0000
Responsible-Changed-Why:
gnats-admin isn't supposed to own PRs.
From: Hubert Feyrer <hubert@feyrer.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/39347
Date: Sun, 16 Nov 2008 14:51:20 +0100 (CET)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-527370721-1226843480=:16005
Content-Type: TEXT/PLAIN; format=flowed; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
The commit at
http://mail-index.netbsd.org/source-changes/2008/11/16/msg212783.html
fixes the first of the two example programs, the second one still doesn't
parse the real number properly, and it prints nonsense for the string.
Tested on 5.0_BETA:
Before:
vmnetbsd% uname -rms
NetBSD 5.0_BETA i386
vmnetbsd% ./pr-39347-1
Segmentation fault (core dumped)
vmnetbsd% ./pr-39347-2
Enter an integer, a real number, a character and a string :
17 17.42 f bar
integer = 17
real number = 0.000000
character = b
string = º»´x¾»Hë¿¿UG¿»²»P
After:
vmnetbsd% env LD_LIBRARY_PATH=/usr/cvs/src-5/obj.i386/destdir/lib
./pr-39347-1
10
vmnetbsd% env LD_LIBRARY_PATH=/usr/cvs/src-5/obj.i386/destdir/lib
./pr-39347-2
Enter an integer, a real number, a character and a string :
17 17.42 f bar
integer = 17
real number = 0.000000
character = b
string = ¿¿UG¿»Ô÷±»P
FWIW, here's the output on Mac OS X 10.4:
mini% ./pr-39347-1
10
mini% ./pr-39347-2
Enter an integer, a real number, a character and a string :
17 17.42 f bar
integer = 17
real number = 17.420000
character = f
string = bar
mini% uname -a
Darwin mini.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386
- Hubert
--8323328-527370721-1226843480=:16005--
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39347 CVS commit: src/lib/libc/stdio
Date: Sun, 16 Nov 2008 16:26:01 +0000 (UTC)
Module Name: src
Committed By: christos
Date: Sun Nov 16 16:26:01 UTC 2008
Modified Files:
src/lib/libc/stdio: vfwscanf.c
Log Message:
PR/39347: floating and long double conversions were ifdef'ed out because
we did not have wcstold and wcstof back then. But this was done incorrectly
because we did not move the argument vector. Enable them now.
To generate a diff of this commit:
cvs rdiff -r1.3 -r1.4 src/lib/libc/stdio/vfwscanf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 03 May 2010 05:58:45 +0000
State-Changed-Why:
The second example works for me on -current amd64 now. Is this good enough
for you or should we look into getting the fixes pulled up to the release
branches?
From: Matthias Kretschmer <kretschm@cs.uni-bonn.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/39347 (*wscanf bug)
Date: Fri, 2 Jul 2010 07:37:37 +0200
Hello,
On Mon, May 03, 2010 at 05:58:46AM +0000, dholland@NetBSD.org wrote:
> The second example works for me on -current amd64 now. Is this good enough
> for you or should we look into getting the fixes pulled up to the release
> branches?
sorry for the late reply.
I'm not using current. I installed -CURRENT in qemu to check
myself and it seems to work properly now. In the meantime I was
using another workaround in one of my projects where I found this
bug. At the moment I do not need it in the release branches, but
I think it would be great to have it integrated at least in the
next upcoming 5.1 release.
Best regards,
Matthias Kretschmer
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/39347 (*wscanf bug)
Date: Sun, 4 Jul 2010 20:26:59 +0000
On Fri, Jul 02, 2010 at 05:40:03AM +0000, Matthias Kretschmer wrote:
> sorry for the late reply.
Not a problem, except...
> I'm not using current. I installed -CURRENT in qemu to check
> myself and it seems to work properly now. In the meantime I was
> using another workaround in one of my projects where I found this
> bug. At the moment I do not need it in the release branches, but
> I think it would be great to have it integrated at least in the
> next upcoming 5.1 release.
...it's too late for 5.1 at this point.
The first fix is in 5.0; I can ask to get the second fix pulled up
after 5.1 goes out, so it'll be in the stable branch and in 5.2 if
there ever is a 5.2.
If the fixes in work in netbsd-4 I can also have them pulled up to the
netbsd-4 stable branch; the first one ought to work but I'm not sure
about the second one and (for the moment at least) I can't test it all
that readily myself...
--
David A. Holland
dholland@netbsd.org
From: Matthias Kretschmer <kretschm@cs.uni-bonn.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/39347 (*wscanf bug)
Date: Tue, 13 Jul 2010 07:57:19 +0200
Hello,
On Sun, Jul 04, 2010 at 08:30:05PM +0000, David Holland wrote:
> Not a problem, except...
> ...it's too late for 5.1 at this point.
>
> The first fix is in 5.0; I can ask to get the second fix pulled up
> after 5.1 goes out, so it'll be in the stable branch and in 5.2 if
> there ever is a 5.2.
that's great to hear. It would be great to have them in anything after
5.1 when it is released (netbsd-5-1 and netbsd-5 branches).
> If the fixes in work in netbsd-4 I can also have them pulled up to the
> netbsd-4 stable branch; the first one ought to work but I'm not sure
> about the second one and (for the moment at least) I can't test it all
> that readily myself...
I have a single box running NetBSD 4 at the moment and I plan to upgrade
it and so _I_ do not require it in 4.
Thank you for your help/work/patch.
Regards,
Matthias Kretschmer
State-Changed-From-To: feedback->open
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 31 Jan 2011 02:35:55 +0000
State-Changed-Why:
feedback was received back in July; what's needed now is pullup to -5 nd
perhaps -4.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 19 Dec 2015 02:37:39 +0000
State-Changed-Why:
-5 is now EOL, it's fixed in -6 and up
>Unformatted:
swscanf crashes on i386, wscanf returns bad values
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.