I'm currently running a program on a APU under Linux on top of Mono (C# code). The APU is:
- Carrizo (rev 4) APU
- Linux Ubuntu 16.04
- AMD driver: 16.50_amdgpu-pro_326352
The issue I'm getting is that Mono is throwing a managed exception because the AMD driver is closing a file descriptor Mono is using which should not have been closed.
I was able to get the call stack when the AMD driver is closing the file descriptor opened by Mono:
#0 close () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007fffe19067be in Pal::Linux::GpuMemory::~GpuMemory() () from /opt/amdgpu-pro/lib/x86_64-linux-gnu/amdvlk64.so
#2 0x00007fffe1ec0516 in vk::Memory::Free(vk::Device*) () from /opt/amdgpu-pro/lib/x86_64-linux-gnu/amdvlk64.so
#3 0x00007fffe1ec43c6 in vk::SwapChain::Destroy() () from /opt/amdgpu-pro/lib/x86_64-linux-gnu/amdvlk64.so
#4 0x00007fffe141a062 in unique_objects::DestroySwapchainKHR (device=0x2618dd0, swapchain=0x27ab180, pAllocator=0x0)
#5 0x00007fffe0f4f374 in swapchain::DestroySwapchainKHR (device=0x2618dd0, swapchain=0x18, pAllocator=0x0)
#6 0x00007fffe0afe709 in core_validation::DestroySwapchainKHR (device=0x2618dd0, swapchain=0x18, pAllocator=0x0)
#7 0x00007fffe026d2a9 in object_tracker::DestroySwapchainKHR (device=0x2618dd0, swapchain=0x18, pAllocator=0x0)
#8 0x00007fffe2474b06 in vkDestroySwapchainKHR (device=0x2618dd0, swapchain=0x18, pAllocator=0x0)
I've attached the strace output of the execution. The file descriptor being closed is #23. It is initially open toward the end of the strace by mono to open /dev/urandom. But it is closed 3 times by the AMD driver, the first time successfully, then with failure. And when Mono tries to read from it later, it fails of course (last line of the trace).
It is as if the AMD driver is closing the file descriptor without resetting some internal value and later if the file descriptor is open without checking if it did open it, it will close it.
This happens regardless of using OpenGL or Vulkan as the backend graphic API (although here I used the Vulkan backend).