Bug 51144 - Clang -Wcast-align gives an error in WebBasePluginPackage.mm
Summary: Clang -Wcast-align gives an error in WebBasePluginPackage.mm
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Plug-ins (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Cameron Zwarich (cpst)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-15 15:25 PST by Cameron Zwarich (cpst)
Modified: 2010-12-21 10:51 PST (History)
4 users (show)

See Also:


Attachments
Proposed patch (4.47 KB, patch)
2010-12-15 17:34 PST, Cameron Zwarich (cpst)
darin: review+
zwarich: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Zwarich (cpst) 2010-12-15 15:25:05 PST
Clang -Wcast-align gives an error in WebBasePluginPackage.mm. This is the only error, so we might as well fix it.
Comment 1 Cameron Zwarich (cpst) 2010-12-15 17:34:56 PST
Created attachment 76716 [details]
Proposed patch
Comment 2 Cameron Zwarich (cpst) 2010-12-15 20:35:27 PST
Fixed in r74172.
Comment 3 WebKit Review Bot 2010-12-16 15:37:59 PST
http://trac.webkit.org/changeset/74172 might have broken Leopard Intel Debug (Tests)
Comment 4 Nikolas Zimmermann 2010-12-21 05:53:04 PST
Since this patch is in, I can't use DRT on Leopard anymore:

Exception Codes: KERN_INVALID_ADDRESS at 0x00000000bbadbeef
Crashed Thread:  0

Thread 0 Crashed:
0   com.apple.WebKit              	0x00d50a34 WTF::VectorBufferBase<unsigned int>::allocateBuffer(unsigned long) + 38 (Vector.h:286)
1   com.apple.WebKit              	0x00d50a9b WTF::VectorBuffer<unsigned int, 128ul>::VectorBuffer(unsigned long) + 67
2   com.apple.WebKit              	0x00d50acd WTF::Vector<unsigned int, 128ul>::Vector(unsigned long) + 47
3   com.apple.WebKit              	0x00d4ecc5 -[WebBasePluginPackage isNativeLibraryData:] + 69 (WebBasePluginPackage.mm:356)
4   com.apple.WebKit              	0x00df1e18 -[WebPluginPackage initWithPath:] + 550 (WebPluginPackage.mm:67)
5   com.apple.WebKit              	0x00d4e9b0 +[WebBasePluginPackage pluginWithPath:] + 72 (WebBasePluginPackage.mm:79)
6   com.apple.WebKit              	0x00defcf4 -[WebPluginDatabase(Internal) _scanForNewPlugins] + 442 (WebPluginDatabase.mm:488)
7   com.apple.WebKit              	0x00df0980 -[WebPluginDatabase refresh] + 192 (WebPluginDatabase.mm:272)
8   com.apple.WebKit              	0x00df1121 +[WebPluginDatabase sharedDatabase] + 189 (WebPluginDatabase.mm:72)
9   DumpRenderTree                	0x00012f28 __ZL32addTestPluginsToPluginSearchPathPKc + 146
10  DumpRenderTree                	0x0001651f dumpRenderTree(int, char const**) + 43
11  DumpRenderTree                	0x00016874 main + 94 (DumpRenderTree.mm:711)
12  DumpRenderTree                	0x00002b6a start + 54
Comment 5 Nikolas Zimmermann 2010-12-21 05:53:21 PST
(In reply to comment #4)
> Since this patch is in, I can't use DRT on Leopard anymore:
To clarify, it crashes on every test.
Comment 6 Nikolas Zimmermann 2010-12-21 06:09:18 PST
Comment on attachment 76716 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=76716&action=review

> WebKit/mac/Plugins/WebBasePluginPackage.mm:355
> +    NSUInteger sizeInBytes = [data length];
> +    Vector<uint32_t, 128> rawData((sizeInBytes - 1) / 4 + 1);

This silently assumes sizeInBytes > 0. The crash I see happens with sizeInBytes=0.
So using sizeInBytes > 0 ? ((sizeInBytes - 1) / 4 + 1) : 0, should fix the problem.
Comment 7 Cameron Zwarich (cpst) 2010-12-21 10:51:32 PST
(In reply to comment #6)
> (From update of attachment 76716 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=76716&action=review
> 
> > WebKit/mac/Plugins/WebBasePluginPackage.mm:355
> > +    NSUInteger sizeInBytes = [data length];
> > +    Vector<uint32_t, 128> rawData((sizeInBytes - 1) / 4 + 1);
> 
> This silently assumes sizeInBytes > 0. The crash I see happens with sizeInBytes=0.
> So using sizeInBytes > 0 ? ((sizeInBytes - 1) / 4 + 1) : 0, should fix the problem.

r=me on that, I was going to land this fix myself