Bug 22184

Summary: fcvt() returns string not correctly
Product: [Retired] Red Hat Linux Reporter: jianhua zhou <jianhua.zhou>
Component: compat-glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 6.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-12-18 18:04:47 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 jianhua zhou 2000-12-12 22:12:39 UTC
There is a small program and generate the different result on 6.1 and 6.2.

This is the small program:

main()
{
        int decpnt, neg;

        printf("%s\n", fcvt(19.0, 16, &decpnt, &neg));
        printf("%d\n", decpnt);
        printf("%s\n", fcvt(322.45, 16, &decpnt, &neg));
        printf("%d\n", decpnt);
        printf("%s\n", fcvt(9.44, 16, &decpnt, &neg));
        printf("%d\n", decpnt);
        printf("%s\n", fcvt(9.0, 16, &decpnt, &neg));
        printf("%d\n", decpnt);
}

On 6.2, when build and run, the output is:

190000000000000000
2
322.449999999999988
2
94399999999999995
1
90000000000000000
1

when build on 6.1 and run it, the output is :
190000000000000000
2
322449999999999988
3
94399999999999995
1
90000000000000000
1

Looks like the fcvt() has some problem on 6.2. We notice that
one of the library called "glibc" has the different version on
61 and 62, the one on 61 has the version: 2.1.2., and on 6.2
it is 2.1.3. If we install the old version (2.1.2) on 62, then
the problem disappears.


Jianhua
303-294-4775

Comment 1 Jakub Jelinek 2000-12-13 12:38:40 UTC
I've mailed a patch for this at http://sources.redhat.com/ml/libc-hacker/2000-12/msg00039.html
Am now waiting for feedback from other glibc hackers.

Comment 2 jianhua zhou 2000-12-18 18:04:42 UTC
Do you think i can able to get the patch and put on my machine to test someday?

Comment 3 Jakub Jelinek 2000-12-19 09:39:18 UTC
Fixed in glibc-2.2-9 errata (together with other fixes).
As this problem is not severe enough to justify errata for older glibcs, there
won't be any errata for glibc-2.1.x because of this.
Use fcvt_r if you're building programs against older libcs (and pass a
sufficiently large buffer to it). Or you can use sprintf and memmove the
decimal dot out...

Comment 4 jianhua zhou 2000-12-19 16:41:18 UTC
I cannot find any manual for fcvt_r().
I can use ecvt(), but it is a little different.
I can use gcvt(), sprintf(), then the logical is changed, i have to mantain
the result by by myself, so for our database product, i don't think it is
a good way to make these kind of change, because this is means, everywhere
we called the fcvt(), we need free the memory sometime after, but previously,
we don't need do that.

So we cannot say, this problem is not important.