<html>
    <head>
      <base href="https://bugs.dpdk.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8" class="bz_new_table">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - rte_malloc_socket failed to allocate with large alignment and ASan"
   href="https://bugs.dpdk.org/show_bug.cgi?id=1708">1708</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>rte_malloc_socket failed to allocate with large alignment and ASan
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>DPDK
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>21.11
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>core
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dev@dpdk.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>plestringant@kalrayinc.com
          </td>
        </tr>

        <tr>
          <th>Target Milestone</th>
          <td>---
          </td>
        </tr></table>
      <p>
        <div class="bz_comment_block">
          <pre class="bz_comment_text">After commit f92b9ebed03dbd140a5a7b921cb898e661a59068, I am unable to allocate
1MiB aligned 1MiB with rte_malloc_socket when DPDK is built with ASan.

Enter try_expand_heap_primary with pg_sz=0x200000, elt_size=0x100000,
align=0x100000
alloc_sz is set to 0x200000
Enter alloc_pages_on_heap
Enter find_suitable_element
Enter elem_start_pt with elem of size 0x200000
MALLOC_ELEM_TRAILER_LEN is non zero because of ASan
new_data_start is equal to elem because of alignment
There is no room for the header and it fails.

If my analysis is correct the formula used in try_expand_heap_primary to
compute alloc_sz is off. I suggest something like:

alloc_sz = RTE_ALIGN_CEIL(RTE_ALIGN_CEIL(elt_size + MALLOC_ELEM_TRAILER_LEN,
align) + MALLOC_ELEM_HEADER_LEN, pg_sz);

I am working with branch 21.11, but I think this issue affects all the branches
which contain commit f92b9ebed03dbd140a5a7b921cb898e661a59068
          </pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
      <div itemscope itemtype="http://schema.org/EmailMessage">
        <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
          
          <link itemprop="url" href="https://bugs.dpdk.org/show_bug.cgi?id=1708">
          <meta itemprop="name" content="View bug">
        </div>
        <meta itemprop="description" content="Bugzilla bug update notification">
      </div>
    </body>
</html>