Bug 59477

Summary: Loss of precision errors throughout the codebase spotted by GCC 4.6
Product: WebKit Reporter: Xan Lopez <xan.lopez>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
precission.diff ap: review-

Xan Lopez
Reported 2011-04-26 11:48:35 PDT
GCC 4.6 seems to be more picky about trying to stuff 64bit values into 32bit variables (as it should!). All the cases seem safe to fix by forcefully casting the value, since it seems either impossible (ByteCodeGenerator, UTF8, ...) or extremely unlikely (the string length in FontGtk) that the value would overflow a 32bit value. At worst, we are not really making things worse, but of course in some cases it might make sense to change the code to not force a cast here.
Attachments
precission.diff (8.03 KB, patch)
2011-04-26 11:54 PDT, Xan Lopez
ap: review-
Xan Lopez
Comment 1 2011-04-26 11:54:27 PDT
Created attachment 91136 [details] precission.diff
Alexey Proskuryakov
Comment 2 2011-04-26 16:33:11 PDT
Comment on attachment 91136 [details] precission.diff View in context: https://bugs.webkit.org/attachment.cgi?id=91136&action=review I think that this should be split into parts that domain experts could look at. > Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2102 > + SwitchInfo info = { static_cast<uint32_t>(instructions().size()), type }; I think that this patch is making things worse in that once this warning is enabled in some other compiler, we won't see the issues. It's not obvious to me that malicious code can't create 4 billion instructions. > Source/JavaScriptCore/wtf/unicode/UTF8.cpp:236 > +static const UChar32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, static_cast<const UChar32>(0xFA082080UL), static_cast<const UChar32>(0x82082080UL) }; Can this be fixed by not using UChar32? These are not Unicode characters, these are magic numbers. > Source/WebCore/plugins/PluginPackage.cpp:348 > + static_cast<unsigned int>(m_lastModified) We don't use "unsigned int", we use "unsigned".
Note You need to log in before you can comment on or make changes to this bug.