<?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>314529</bug_id>
          
          <creation_ts>2026-05-10 22:15:28 -0700</creation_ts>
          <short_desc>codePointCompare dereferences pointer to unaligned ChunkType</short_desc>
          <delta_ts>2026-05-12 23:44:12 -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>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Xi Ruoyao">xry111</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2209587</commentid>
    <comment_count>0</comment_count>
    <who name="Xi Ruoyao">xry111</who>
    <bug_when>2026-05-10 22:15:28 -0700</bug_when>
    <thetext>The code reads:

#if CPU(REGISTER64) &amp;&amp; !CPU(NEEDS_ALIGNED_ACCESS) &amp;&amp; CPU(LITTLE_ENDIAN)
    if constexpr (sizeof(CharacterType1) == sizeof(CharacterType2) &amp;&amp; (sizeof(CharacterType1) == 1 || sizeof(CharacterType1) == 2)) {
        using ChunkType = std::conditional_t&lt;sizeof(CharacterType1) == 1, uint32_t, uint64_t&gt;;
        constexpr size_t stride = sizeof(ChunkType) / sizeof(CharacterType1);
        for (; position + (stride - 1) &lt; commonLength;) {
            auto lhs = *std::bit_cast&lt;const ChunkType*&gt;(characters1Ptr);
            auto rhs = *std::bit_cast&lt;const ChunkType*&gt;(characters2Ptr);

... ...

Despite it&apos;s only applied for CPUs not requiring aligned access, dereferencing const ChunkType* causes the compiler to assume the address is naturally aligned for ChunkType and make optimizations based on this assumption.  For example, with GCC 16 and -mavx, the loop is optimized to use a 256-bit vmovdqa after handling 0-3 64-bit scalars, causing a segfault.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2210410</commentid>
    <comment_count>1</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-05-12 23:43:30 -0700</bug_when>
    <thetext>Committed 313136@main (54862905a65e): &lt;https://commits.webkit.org/313136@main&gt;

Reviewed commits have been landed. Closing PR #64655 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2210411</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-05-12 23:44:12 -0700</bug_when>
    <thetext>&lt;rdar://problem/176952645&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>