Bug 25864

Summary: strict aliasing issues in WebCore/page/SecurityOriginHash.h
Product: WebKit Reporter: Craig Schlenter <craig.schlenter>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
attempted fix for strict aliasing issue eric: review-

Description Craig Schlenter 2009-05-19 09:10:08 PDT
I've been compiling chromium with gcc 4.4 and I've had to use -fno-strict-aliasing for webkit due to a couple of issues. The code in question should be equivalent to that in WebKit itself. Here's one of the issues:

In file included from /home/craig/chromium.git/src/third_party/WebKit/WebCore/storage/OriginQuotaManager.h:35,
                 from /home/craig/chromium.git/src/third_party/WebKit/WebCore/storage/DatabaseTracker.cpp:40:
/home/craig/chromium.git/src/third_party/WebKit/WebCore/platform/text/StringImpl.h: In static member function 'static unsigned int WebCore::SecurityOriginHash::hash(WebCore::SecurityOrigin*)':
/home/craig/chromium.git/src/third_party/WebKit/WebCore/platform/text/StringImpl.h:210: warning: dereferencing pointer 'data' does break strict-aliasing rules
/home/craig/chromium.git/src/third_party/WebKit/WebCore/page/SecurityOriginHash.h:46: note: initialized from here
/home/craig/chromium.git/src/third_party/WebKit/WebCore/platform/text/StringImpl.h:213: note: initialized from here
/home/craig/chromium.git/src/third_party/WebKit/WebCore/platform/text/StringImpl.h:211: warning: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/home/craig/chromium.git/src/third_party/WebKit/WebCore/platform/text/StringImpl.h:211: note: initialized from here

I'm attaching a patch which seems to work for me but I have only tested it on linux ... I don't know how other compilers will deal with the union initialisation etc. etc.
Comment 1 Craig Schlenter 2009-05-19 09:12:43 PDT
Created attachment 30472 [details]
attempted fix for strict aliasing issue

only tested on linux with gcc 4.4 in chromium
Comment 2 Darin Adler 2009-05-19 09:30:18 PDT
Comment on attachment 30472 [details]
attempted fix for strict aliasing issue

In the past, WebCore has not been compiled with strict aliasing turned on. Unlike JavaScriptCore, where we fixed all the strict aliasing issues.

I would expect many, many problems in WebCore. Not just warnings, but actual code generation problems. Do we really want to do this project (turning on strict aliasing in WebCore)?
Comment 3 Evan Martin 2009-05-19 10:06:44 PDT
I take Darin's comment to mean that in the interim, we should turn off strict aliasing in Chrome for now.
Comment 4 Peter Kasting 2009-05-19 11:06:27 PDT
Over time we should definitely fix strict aliasing problems.  GCC is not the only compiler where they can cause issues.  Generally they are easy to fix by adding unions (I would probably elect to use more typedefs in the particular patch above for clarity, though).
Comment 5 Eric Seidel (no email) 2009-05-19 22:45:08 PDT
Comment on attachment 30472 [details]
attempted fix for strict aliasing issue

bug 16317 is another way to make this code cleaner.  But given the above comments, I think we should close this and someone who is interested in turning on strict aliasing warnings for WebCore can do this for real later.
Comment 6 Eric Seidel (no email) 2009-05-19 22:45:42 PDT
WONTFIX based on the above comments.  Feel free to open a more general bug about turning on strict aliasing in WebCore.