<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - vkAllocateDeviceMemory does not check memory heap size"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=102704">102704</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>vkAllocateDeviceMemory does not check memory heap size
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

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

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/Vulkan/intel
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nioko1337@googlemail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jason@jlekstrand.net
          </td>
        </tr></table>
      <p>
        <div>
        <pre>So there is a vulkan wrapper called vulkano (written in rust), and one test
case in particular fails on anv.

The code snippet allocates more memory than reported by vkMemoryHeap.size, but
in multiple allocations. I would expect this to fail with
VK_ERROR_OUT_OF_DEVICE_MEMORY, but it doesn't.

I currently only have a rust code snippet, but from the code it should be
obvious what's happening under the hood:

    #[test]
    #[ignore] // TODO: test fails for now on Mesa+Intel
    fn oom_multi() {
        let (device, _) = gfx_dev_and_queue!();
        let mem_ty = device
            .physical_device()
            .memory_types()
            .filter(|m| !m.is_lazily_allocated())
            .next()
            .unwrap();
        let heap_size = mem_ty.heap().size();

        let mut allocs = Vec::new();

        for _ in 0 .. 4 {
            match DeviceMemory::alloc(device.clone(), mem_ty, heap_size / 3) {
               
Err(DeviceMemoryAllocError::OomError(OomError::OutOfDeviceMemory)) => return,
// test succeeded
                Ok(a) => allocs.push(a),
                _ => (),
            }
        }

        panic!()
    }</pre>
        </div>
      </p>


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

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>