<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>20990</bug_id>
          
          <creation_ts>2008-09-22 06:54:08 -0700</creation_ts>
          <short_desc>FreeBSD Alpha, &gt;3000 cast alignment warnings on build, unaligned access errors on run</short_desc>
          <delta_ts>2022-07-11 15:17:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Other</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>DoNotImportToRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Anton Shterenlikht">mexas</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>bfulgham</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>92120</commentid>
    <comment_count>0</comment_count>
    <who name="Anton Shterenlikht">mexas</who>
    <bug_when>2008-09-22 06:54:08 -0700</bug_when>
    <thetext>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&apos; 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; &quot;log&quot; is the file with all build output.
# grep -c alignment log
3293

of which the major culprits are:

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

and the minor worries are:

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

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


many thanks
anton</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92129</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-22 08:07:33 -0700</bug_when>
    <thetext>See also: bug 19775.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92486</commentid>
    <comment_count>2</comment_count>
    <who name="Anton Shterenlikht">mexas</who>
    <bug_when>2008-09-24 01:28:02 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; See also: bug 19775.
&gt; 

thanks. Regarding this fix:

+#if PLATFORM(ARM) || PLATFORM(SPARC64)
+            const UChar* aChars = a-&gt;characters();
+            const UChar* bChars = b-&gt;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92523</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-24 08:12:10 -0700</bug_when>
    <thetext>I think the latter would be correct, as FreeBSD on other platforms doesn&apos;t need this change (which likely affects performance negatively).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92707</commentid>
    <comment_count>4</comment_count>
    <who name="Anton Shterenlikht">mexas</who>
    <bug_when>2008-09-25 06:51:04 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; See also: bug 19775.
&gt; 

The patches to 

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

were successful. I reduced the number of alignment warnings from &gt;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 &apos;uint32_t*&apos; to &apos;WTF::ListHashSetNode&lt;WebCore::HTMLFormControlElementWithState*&gt;*&apos; 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&lt;Node*&gt;(m_pool.pool); }
+        Node* pool() { return reinterpret_cast&lt;Node*&gt;(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&lt;typename ValueArg&gt; struct ListHashSetNode {

Line 169 is the one with reinterpred_cast.

Not sure what to do next.
anton</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>