<?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>231917</bug_id>
          
          <creation_ts>2021-10-18 16:02:12 -0700</creation_ts>
          <short_desc>[bmalloc] Heap.shrinkLarge() allocates non-aligned region</short_desc>
          <delta_ts>2021-10-25 16:03:18 -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>bmalloc</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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="Basuke Suzuki">basuke</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1805756</commentid>
    <comment_count>0</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2021-10-18 16:02:12 -0700</bug_when>
    <thetext>Because the newly allocated region is not aligned well, unaligned region will be returned to LargeFree while splitAndAllocate() is called. Those regions won&apos;t match to any request to LargeFree until the neighbor region is returned to LargeFree and get merged with that.

1. Align 40k memory region A. Both start and end is aligned in 4k boundary.
2. realloc A to 36k + 1. shrinkLarge tries to split it in that size, B (36k +1) and C (4k - 1)
3. B&apos;s end is not aligned, but there&apos;s no practical issue.
4. On the other hand, C&apos;s start address is not aligned and sit in the LargeFree. It won&apos;t fit to any request because it&apos;s not aligned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1805790</commentid>
    <comment_count>1</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2021-10-18 17:09:42 -0700</bug_when>
    <thetext>Above description was wrong. Rewrote.

Because the newly allocated region is not aligned well, unaligned region will be returned to LargeFree while splitAndAllocate() is called. Those regions won&apos;t match to any request to LargeFree until the neighbor region is returned to LargeFree and get merged with that.

1. Align 40k memory region A. Both start and end is aligned in 4k boundary.
2. realloc A to 36k + 8. shrinkLarge tries to split it in that size, B (36k +8) and C (4k - 8)
3. B&apos;s end is not aligned, but there&apos;s no practical issue.
4. On the other hand, C&apos;s start address is not aligned and sit in the LargeFree. It won&apos;t fit to any request because it&apos;s not aligned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1808648</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-10-25 16:03:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/84635991&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>