Bug 20990 - FreeBSD Alpha, >3000 cast alignment warnings on build, unaligned access errors on run
Summary: FreeBSD Alpha, >3000 cast alignment warnings on build, unaligned access error...
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL:
Keywords: DoNotImportToRadar
Depends on:
Blocks:
 
Reported: 2008-09-22 06:54 PDT by Anton Shterenlikht
Modified: 2022-07-11 15:17 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Shterenlikht 2008-09-22 06:54:08 PDT
I built webkit-gtk2-0.0.30549_1 from ports on FreeBSD 6.3-stable on Alpha.
I had 3293 alignment warnings. The details are below.
I use webkit with kazehakase web browser, also built from ports.
Kazehakase was built with xulrunner as well.
When I ran kazehakase with xulrunner all is well.
With webkit I get literally hundreds of messages like this:

pid 83623 (kazehakase): unaligned access: va=0x1661aa90e pc=0x164855bb8 ra=0x1648550ac op=ldl

or

** (gecko:83623): CRITICAL **: void webkit_web_view_open(WebKitWebView*, const gchar*): assertion `uri' failed

With webkit, kazehakase does not load pages, and is otherwise not
very responsive.

I wonder if the alignment warnings on build show themselves as unaligned
access errors on run?

******************************

The alignment warning statistics on build; "log" is the file with all build output.
# grep -c alignment log
3293

of which the major culprits are:

#grep -c "./JavaScriptCore/wtf/Vector.h:380: warning: cast from" log
1414
#grep -c "WebCore/platform/text/StringHash.h:45: warning: cast from" log
642
#grep -c "WebCore/platform/text/StringHash.h:46: warning: cast from" log
642
#grep -c "./JavaScriptCore/wtf/ListHashSet.h:169: warning: cast from" log
586

and the minor worries are:

#grep -c "JavaScriptCore/kjs/dtoa.cpp:2575: warning: cast from" log 
2
#grep -c "WebCore/platform/text/AtomicString.cpp:117: warning: cast from" log
1
#grep -c "WebCore/platform/text/AtomicString.cpp:118: warning: cast from" log
1
#grep -c "WebCore/rendering/RenderLayer.cpp:113: warning: cast from" log
1
#grep -c "WebCore/rendering/RootInlineBox.cpp:56: warning: cast from" log
1
#grep -c "JavaScriptCore/pcre/pcre_compile.cpp:2523: warning: cast from" log 
1
#grep -c "JavaScriptCore/kjs/property_map.cpp:111: warning: cast from" log 
1
#grep -c "./JavaScriptCore/wtf/FastMalloc.cpp:2141: warning: cast from" log 
1

642+642+1414+586+2+7*1 = 3293


many thanks
anton
Comment 1 Alexey Proskuryakov 2008-09-22 08:07:33 PDT
See also: bug 19775.
Comment 2 Anton Shterenlikht 2008-09-24 01:28:02 PDT
(In reply to comment #1)
> See also: bug 19775.
> 

thanks. Regarding this fix:

+#if PLATFORM(ARM) || PLATFORM(SPARC64)
+            const UChar* aChars = a->characters();
+            const UChar* bChars = b->characters();
+            for (unsigned i = 0; i != aLength; ++i)
+                if (*aChars++ != *bChars++)
+                    return false;
+
+            return true;
+#else

what shall I use for PLATFORM,- FREEBSD or ALPHA ?

thanks
Comment 3 Alexey Proskuryakov 2008-09-24 08:12:10 PDT
I think the latter would be correct, as FreeBSD on other platforms doesn't need this change (which likely affects performance negatively).
Comment 4 Anton Shterenlikht 2008-09-25 06:51:04 PDT
(In reply to comment #1)
> See also: bug 19775.
> 

The patches to 

JavaScriptCore/wtf/Vector.h:
WebCore/platform/text/StringHash.h

were successful. I reduced the number of alignment warnings from >3000
down to 600.

However, the patch for JavaScriptCore/wtf/ListHashSet.h is not having the
effect:

./JavaScriptCore/wtf/ListHashSet.h:169: warning: cast from 'uint32_t*' to 'WTF::ListHashSetNode<WebCore::HTMLFormControlElementWithState*>*' increases required alignment of target type

I applied the patch just as in bug report 19775:

--- JavaScriptCore/wtf/ListHashSet.h.orig	Tue Jul  8 23:23:01 2008
+++ JavaScriptCore/wtf/ListHashSet.h	Tue Jul  8 23:24:03 2008
@@ -122,7 +122,7 @@ namespace WTF {
             : m_freeList(pool())
             , m_isDoneWithInitialFreeList(false)
         { 
-            memset(m_pool.pool, 0, sizeof(m_pool.pool));
+            memset(m_pool, 0, sizeof(m_pool));
         }
 
         Node* allocate()
@@ -166,7 +166,7 @@ namespace WTF {
         }
 
     private:
-        Node* pool() { return reinterpret_cast<Node*>(m_pool.pool); }
+        Node* pool() { return reinterpret_cast<Node*>(m_pool); }
         Node* pastPool() { return pool() + m_poolSize; }
 
         bool inPool(Node* node)
@@ -177,10 +177,7 @@ namespace WTF {
         Node* m_freeList;
         bool m_isDoneWithInitialFreeList;
         static const size_t m_poolSize = 256;
-        union {
-            char pool[sizeof(Node) * m_poolSize];
-            double forAlignment;
-        } m_pool;
+        uint32_t m_pool[(sizeof(Node) * m_poolSize + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
     };
 
     template<typename ValueArg> struct ListHashSetNode {

Line 169 is the one with reinterpred_cast.

Not sure what to do next.
anton