Closed goossens closed 7 months ago
I'm not getting that crash. Try changing line 575 in renderer_vk.cpp to:
allocator->realloc(_memory, 0, kMinAlignment, "vkFree", 0);
This should fix, but since I couldn't reproduce it here, I would need you to verify it.
Unfortunately, that didn't solve the problem. I did some more digging and here is what I found:
I still don't know what causes it but hopefully, it gives you some clues. Here's my output from running examplesDebug in gdb (the alloc statements at the top are from a poor mans's debugging attempt):
alloc: 48 alloc: 64 alloc: 0 free(): invalid pointer
Thread 3 "examplesDebug" received signal SIGABRT, Aborted. [Switching to Thread 0x7fffd7da2640 (LWP 25612)] __pthread_kill_implementation (no_tid=0, signo=6, threadid=140736814786112) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt
0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140736814786112) at ./nptl/pthread_kill.c:44
1 __pthread_kill_internal (signo=6, threadid=140736814786112) at ./nptl/pthread_kill.c:78
2 __GI___pthread_kill (threadid=140736814786112, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
3 0x00007ffff7842476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
4 0x00007ffff78287f3 in __GI_abort () at ./stdlib/abort.c:79
5 0x00007ffff7889676 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff79dbb77 "%s\n")
at ../sysdeps/posix/libc_fatal.c:155
6 0x00007ffff78a0cfc in malloc_printerr (str=str@entry=0x7ffff79d9744 "free(): invalid pointer") at ./malloc/malloc.c:5664
7 0x00007ffff78a2a44 in _int_free (av=
, p= , have_lock=0) at ./malloc/malloc.c:4439 8 0x00007ffff78a5453 in __GI___libc_free (mem=
) at ./malloc/malloc.c:3391 9 0x0000555555777c8a in bgfx::AllocatorStub::realloc (this=0x7fffdc001680, _ptr=0x7fffd7da0560, _size=0, _align=0,
_file=0x555555a83b03 "vkFree", _line=0) at ../../../src/bgfx.cpp:198
10 0x000055555557abe9 in bx::free (_allocator=0x7fffdc001680, _ptr=0x7fffd7da0560, _align=0, _location=...)
at ../../../../bx/include/bx/inline/allocator.inl:42
11 0x000055555557add8 in bx::alignedFree (_allocator=0x7fffdc001680, _ptr=0x7fffd7da0560, _align=16, _location=...)
at ../../../../bx/include/bx/inline/allocator.inl:67
12 0x0000555555777cc1 in bgfx::AllocatorStub::realloc (this=0x7fffdc001680, _ptr=0x7fffd7da0560, _size=0, _align=16,
_file=0x555555a83b03 "vkFree", _line=0) at ../../../src/bgfx.cpp:202
13 0x00005555557f0529 in bgfx::vk::freeFunction (_userData=0x7fffdc001680, _memory=0x7fffd7da0560)
at ../../../src/renderer_vk.cpp:578
14 0x00007fffd4b10f69 in ?? () from /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so
15 0x00007fffd4b182b3 in ?? () from /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so
16 0x00007fffd4b2333e in ?? () from /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so
17 0x00007fffd4b0f489 in ?? () from /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so
18 0x00005555557f1881 in bgfx::vk::setImageMemoryBarrier (_commandBuffer=0x7fffd0615cb0, _image=..., _aspectMask=6,
_oldLayout=VK_IMAGE_LAYOUT_UNDEFINED, _newLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, _baseMipLevel=0, _levelCount=4294967295, _baseArrayLayer=0, _layerCount=4294967295) at ../../../src/renderer_vk.cpp:1091
19 0x00005555557fa034 in bgfx::vk::TextureVK::setImageMemoryBarrier (this=0x7fffd73789e0, _commandBuffer=0x7fffd0615cb0,
_newImageLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, _singleMsaaImage=false) at ../../../src/renderer_vk.cpp:6396
Grab latest.
That's it, you fixed it. Both the examples and my app now start just fine. Thanks for the quick help!!!
What's your GPU/driver? I want to see to reproduce it locally to understand what's going on.
Well, this is going to shock you.
My main development machine is a 2018 Mac Mini (x86 with 16 GB of memory and embedded Intel UHD Graphics 630 1536 MB). Initially, I was using OpenGL to have some sort of cross platform compatibility. When I moved away from OpenGL, I did not fully want to commit to Metal and this is how I found your library. As I’m fully retired, I have no commercial ambitions. If I can get things running in Metal on MacOS, in Vulkan on Linux and in Direct3D on Windows, I’ll have all the brain exercises I could ever want to keep me mentally healthy.
So here is my typical workflow:
Obviously, the Virtual Machines aren’t speed devils specially given that they share a poor UHD Graphics 630 GPU. It does however work. My logic is that when I move to better (and dedicated) hardware, things can only improve.
To prove that I’m certifiably insane, I’m using CMake as my build environment. Once I got that figured out, it works well and the script for BGFX is only 50 lines (excluding BIMG and BX).
To answer the driver question, on Ubuntu 22.04, I get:
lshw -c video
*-display
description: VGA compatible controller product: SVGA II Adapter vendor: VMware physical id: f bus info: pci@0000:00:0f.0 logical name: /dev/fb0 version: 00 width: 32 bits clock: 33MHz capabilities: vga_controller bus_master cap_list rom fb configuration: depth=32 driver=vmwgfx latency=64 resolution=1280,800 resources: irq:16 ioport:2140(size=16) memory:f0000000-f7ffffff memory:fb800000-fbffffff memory:c0000-dffffmodinfo vmwgfx
filename: /lib/modules/6.5.0-26-generic/kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko version: 2.20.0.0 license: GPL and additional rights description: Standalone drm driver for the VMware SVGA device author: VMware Inc. and others import_ns: DMA_BUF srcversion: B41144FE71C1D39FBA6E54A
Describe the bug
After commit 2ad67a4, I can no longer start my application nor the examples on Ubuntu 22.04 using Vulkan. Both crash with a core dump caused by a "free(): invalid pointer" error. See console output and stack trace below. If I go back to the commit before 2ad67a4, everything starts up just fine.
To Reproduce
Expected behavior
Screenshots
Additional context
Last console output:
Backtrace from my application (but examples show the same)