wgpu: Leaking buffers macOS?

I haven’t got a small reproducible case, but it looks like I’m seeing leaking memory. Using wgpu-rs on macOS. AMD Radeon Pro Vega 56 DiscreteGpu Metal

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: AllocationError(OutOfMemory(Device))', /Users/ln/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/05ba7a5/wgpu-core/src/device/mod.rs:328:22
stack backtrace:
   0:        0x107737575 - backtrace::backtrace::libunwind::trace::h5c84db184dbe55ed
                               at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:        0x107737575 - backtrace::backtrace::trace_unsynchronized::hfabf504f184a4062
                               at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:        0x107737575 - std::sys_common::backtrace::_print_fmt::hb18545a457444b58
                               at src/libstd/sys_common/backtrace.rs:77
   3:        0x107737575 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hff7732c2e44ef8b9
                               at src/libstd/sys_common/backtrace.rs:59
   4:        0x107754bad - core::fmt::write::hd42cb3dea57bae40
                               at src/libcore/fmt/mod.rs:1052
   5:        0x107734f3b - std::io::Write::write_fmt::ha39f6009af02b1d2
                               at src/libstd/io/mod.rs:1426
   6:        0x10773938a - std::sys_common::backtrace::_print::h5cfb8cdd320f1e64
                               at src/libstd/sys_common/backtrace.rs:62
   7:        0x10773938a - std::sys_common::backtrace::print::hef683e3bc77ce269
                               at src/libstd/sys_common/backtrace.rs:49
   8:        0x10773938a - std::panicking::default_hook::{{closure}}::h389f076017b5df43
                               at src/libstd/panicking.rs:204
   9:        0x10773908a - std::panicking::default_hook::h04b06ec20c41bf02
                               at src/libstd/panicking.rs:224
  10:        0x1077399dd - std::panicking::rust_panic_with_hook::hccde7faed9a5c398
                               at src/libstd/panicking.rs:472
  11:        0x1077395a2 - rust_begin_unwind
                               at src/libstd/panicking.rs:380
  12:        0x107767ebf - std::panicking::begin_panic::hc520a8a43176ea4c
  13:        0x107767dc5 - std::panicking::begin_panic::hc520a8a43176ea4c
  14:        0x106eff899 - core::result::Result<T,E>::unwrap::hfdd5819c5946a227
                               at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/result.rs:963
  15:        0x106e3fd8c - wgpu_core::device::Device<B>::create_buffer::h40f8e83dda14e0f2
                               at /Users/ln/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/05ba7a5/wgpu-core/src/device/mod.rs:328
  16:        0x106da5b15 - wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_create_buffer_mapped::h93275aab33da2756
                               at /Users/ln/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/05ba7a5/wgpu-core/src/device/mod.rs:554
  17:        0x106e43bbc - wgpu_device_create_buffer_mapped
                               at /Users/ln/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/05ba7a5/wgpu-native/src/device.rs:215
  18:        0x106d39d19 - wgpu::Device::create_buffer_mapped::h9cd4b0ad4b3c5391
                               at /Users/ln/.cargo/git/checkouts/wgpu-rs-40ea39809c03c5d8/e198d63/src/lib.rs:946
  19:        0x106d39e75 - wgpu::Device::create_buffer_with_data::h2645df23584f5aa9
                               at /Users/ln/.cargo/git/checkouts/wgpu-rs-40ea39809c03c5d8/e198d63/src/lib.rs:964

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks to your test case, it was not too difficult to track down. Now fixed upstream in https://github.com/gfx-rs/gfx-extras/pull/8 Please pick up the new version by doing cargo update -p gfx-memory.

Confirmed fixes it in the test case, and in my original code. Thank you very much!

Was running your testcase, and I think I got a lead: we never end up calling free_chunk. So the problem is definitely in gfx-memory.

It was this commit to wgpu-rs:

https://github.com/gfx-rs/wgpu-rs/commit/31e80d99b3f06a711a8ee7cc9474016a77c64590

Which pulled in latest wgpu. The commit before this doesn’t panic on my machine.

Looking at that, the wgpu commit when it worked was https://github.com/gfx-rs/wgpu/commit/08e8d406c175579da5ef18c1abf4d6c00e2a9726. Between then and the current wgpu commit (https://github.com/gfx-rs/wgpu/commit/306554600ab7479ec3e54d0c076c71f02474237a) used in wgpu-rs, I’m guessing it’s likely it was the “Port to gfx-extras and gfx-hal-0.5” changes. Only other one that looks like it could be related was “Recycled identity management (#533)”.

Oh interesting, you are just creating a buffer that is being dropped! I can test this for sure, thank you 👍