On 08/06/14 02:55, Mcdaniel, Daryl wrote:
> Jaben, Erik, or Lee: could you please review this?
> Could someone else validate this on Linux and/or ARM?
> Thanks.
>
> StdLib: The formatting for double float values, within the gdtoa
> library, is improper.
>
> When running Enquire.efi, several errors similar to the following are
> produced:
> Maximum exponent = 128
> Maximum number = 3.40282347e+38
>
> *** WARNING: Possibly bad output from printf above
> expected value around 3.40282347e38, bit pattern:
> 11111111 11111111 01111111 01111111
> sscanf gave -inf, bit pattern:
> 00000000 00000000 10000000 11111111
> difference= inf
>
> Overflow doesn’t seem to generate a trap
>
> The memory allocation tests will also fail, sometimes leaving all
> available memory consumed.
>
> The correct output in the above example is:
>
> Maximum exponent = 128
> Maximum number = 3.40282347e+38
> Overflow doesn't seem to generate a trap
>
> The root cause is that all operations on values of Long or ULong type,
> within the gdtoa library, must be 32-bit operations. A previous change
> replaced the Long and ULong definitions with INTN and UINTN,
> respectively. While this is correct for a lot of Linux and NetBSD code,
> it was not correct for this library.
>
> This fix reverts the definitions of ULong and Long back to 32-bit types.
> A descriptive comment has also been added to the U union.
> Additional white-space has been added to tidy up the definitions of the
> word0 and word1 macros.
>
> Verified with Enquire.efi and the ISO/IEC C Library compliance
> Validation Suite.
I wanted to test this patch (RHEL-7.0, gcc-4.8, X64), hence I first
tried to reproduce the problem. Unfortunately, I didn't get far enough
in my repro attempt to see the symptom, because I first get:
> PROPERTIES OF FLOAT
> Base = 2
> Significant base digits = 24 (= at least 6 decimal digits)
> Arithmetic rounds towards nearest
> Tie breaking rounds to even
> Smallest x such that 1.0-base**x != 1.0 = -24
> Smallest x such that 1.0-x != 1.0 = 2.98023259e-08
> !!!! X64 Exception Type - 000000000000000E CPU Apic ID - 00000000 !!!!
> RIP - 000000003D6CAAF1, CS - 0000000000000028, RFLAGS - 0000000000010246
> ExceptionData - 0000000000000002
> RAX - 800000FD1A304565, RCX - 0000003000000010, RDX - 0000000000003FE6
> RBX - 000000004B800000, RSP - 000000003FF69B80, RBP - 000000003FF69F90
> RSI - 0000000000000040, RDI - 000000003D6E2D38
> R8 - 0000000000000018, R9 - 000000003FF9AD7F, R10 - 000000003E6AB6D2
> R11 - 0000000000000040, R12 - 0000000000000000, R13 - 0000000000000000
> R14 - 0000000000000000, R15 - 0000000000000000
> DS - 0000000000000008, ES - 0000000000000008, FS - 0000000000000008
> GS - 0000000000000008, SS - 0000000000000008
> CR0 - 0000000080000033, CR2 - 0000003000000010, CR3 - 000000003FF09000
> CR4 - 0000000000000668, CR8 - 0000000000000000
> DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
> DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
> GDTR - 000000003FEF2D98 000000000000003F, LDTR - 0000000000000000
> IDTR - 000000003FC02018 0000000000000FFF, TR - 0000000000000000
> FXSAVE_STATE - 000000003FF697E0
> !!!! Find PE image
> .../Build/AppPkg/DEBUG_GCC48/X64/AppPkg/Applications/Enquire/Enquire/DEBUG/Enquire.dll
> (ImageBase=000000003D6A5000, EntryPoint=000000003D6A5260) !!!!
Analyzing the RIP:
RIP - ImageBase + (start_address - (EntryPoint - ImageBase)) ==
RIP - ImageBase + start_address - EntryPoint + ImageBase ==
RIP - EntryPoint + start_address ==
0x3D6CAAF1 - 0x3D6A5260 + 0x280 ==
0x25B11
*(*mp) = res;
25afd: 48 8b 45 88 mov -0x78(%rbp),%rax
25b01: 48 8b 08 mov (%rax),%rcx
25b04: 48 8b 85 70 ff ff ff mov -0x90(%rbp),%rax
25b0b: 8b 95 78 ff ff ff mov -0x88(%rbp),%edx
25b11: 48 89 01 mov %rax,(%rcx)
<----------- here
25b14: 89 51 08 mov %edx,0x8(%rcx)
This seems to be from "StdLib/LibC/Stdio/vfscanf.c":
844 if ((flags & SUPPRESS) == 0) {
845 if (flags & LONGDBL) {
846 long double **mp = (long double **)ap;
847 long double res = strtold(buf, &p);
848
849 *(*mp) = res;
<----------- here
850 ap += sizeof(long double *);
851 /*???*/ //*va_arg(ap, long double *) = res;
I think this is the same issue that Olivier raised.
Thanks,
Laszlo
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel