gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

assert(bRes) in vulkan_create_flat_texture aborts on VK_ERROR_OUT_OF_DEVICE_MEMORY, making the graceful OOM retry path unreachable

Open SorenHJohansen opened this issue 1 month ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Are you using any gamescope patches or a forked version of gamescope?

  • [x] The issue occurs on upstream gamescope without any modifications

Current Behavior

gamescope 3.16.28 aborts with SIGABRT roughly 30 minutes into a session when vkAllocateMemory returns VK_ERROR_OUT_OF_DEVICE_MEMORY while it rebuilds its output images. The allocation that fails is a temporary 1080p "blank" texture, and the surrounding code is written to tolerate exactly that failure, but an assert() kills the compositor before the recovery path can run.

This abort has occurred 4 times in 8 days on this machine (2026-09-27 ×2, 2026-10-02, 2026-10-04), always with the same error immediately before the abort. On the two 2026-09-27 occurrences Steam restarted gamescope automatically, so they appeared only as a brief black screen; the 2026-10-02 and 2026-10-04 ones ended the session.

Gamescope's own output immediately before the abort:

[gamescope] [Error] vulkan: vkAllocateMemory failed (VkResult: -2)
gamescope: ../gamescope/src/rendervulkan.cpp:3113: gamescope::OwningRc<CVulkanTexture> vulkan_create_flat_texture(uint32_t, uint32_t, uint8_t, uint8_t, uint8_t, uint8_t): Assertion `bRes' failed.

The systemd-coredump record:

PID:      14713 (gamescope-wl)
TID:      14743 (gamescope-xwm)
Signal:   6 (ABRT) si_code: SI_TKILL
Command:  gamescope -W 3840 -H 2160 -w 2560 -h 1440 -f --hdr-enabled -- .../CONTROLResonant.exe

Steps To Reproduce

Not reliably reproducible on demand. I could not pin down which of the seven state changes at steamcompmgr.cpp fires the remake (output width / height / refresh / rotation / HDR-enabled / HDR-capable / force-HDR-debug); xwm_log's HDR output enabled/disabled line never reached the log. What is reproducible:

  1. Launch a title via gamescope -W 3840 -H 2160 -w 2560 -h 1440 -f --hdr-enabled -- %command% on a 10 GiB NVIDIA card, nested in a Wayland compositor running HDR at 4K.

  2. Let it run until VRAM allocations start failing. On this machine the kernel logs 311 of these 36 seconds after the session starts:

    kernel: NVRM: GPU0 nvAssertOkFailedNoLog: Assertion failed: Out of memory [NV_ERR_NO_MEMORY] (0x00000051) returned from poolAllocate((POOLALLOC *)pCtx, &pPage[i]) @ pool_alloc.c:317
    
  3. Something then changes output geometry or HDR output state, which makes steamcompmgr call vulkan_remake_output_images(), and the allocation inside it fails.

Hardware information

  • Distro: Omarchy 4.0.4-1 (Arch-based), kernel 7.2.5-3-omarchy
  • CPU: AMD Ryzen 5 5600X
  • GPU: NVIDIA GeForce RTX 3080 (10240 MiB), 10de:2206 (GA102)
  • Driver Version: NVIDIA 610.57.04 (nvidia-open-dkms)
  • Monitor: ASUS PG32UCDMR, [email protected], 10-bit (XBGR2101010)

This is a GPU-side failure, not host memory pressure: 31 GiB system RAM with ~14 GiB available and near-empty zram swap at crash time, no Xid faults, no host OOM kills.

Software information

  • Desktop environment: Hyprland (Omarchy), Quickshell bar
  • Session type: wayland (XDG_SESSION_TYPE=wayland)
  • Gamescope version: gamescope version 3.16.28 (gcc 16.2.1), upstream Arch package
  • Gamescope launch command(s): gamescope -W 3840 -H 2160 -w 2560 -h 1440 -f --hdr-enabled -- %command%
  • Title: CONTROL (AppID 3669870), Proton Experimental, SteamLinuxRuntime_4
  • Backend: nested Wayland (xdg_backend), so GetBackend()->UsesVulkanSwapchain() is false

Which gamescope backends have the issue you are reporting?

  • [x] Wayland (default for nested gamescope)
  • [ ] DRM (default for embedded gamescope, i.e. gamescope-session)
  • [ ] SDL
  • [ ] OpenVR

Logging, screenshots, or anything else

The crashing thread's comm is gamescope-xwm, which is misleading: that name comes from pthread_setname_np(pthread_self(), "gamescope-xwm") in steamCompMgrThreadRun() (src/main.cpp), so it is the Steam compositor-manager thread, not an XWayland thread. That fits: vulkan_remake_output_images() has exactly one caller in the tree, src/steamcompmgr.cpp, which runs on that thread.

Three of the four crashes asserted one frame earlier, at rendervulkan.cpp:3387 in vulkan_remake_output_images() (assert(bRet)), having logged failed to allocate buffer for KMS; the 2026-10-04 crash is the one at rendervulkan.cpp:3113 in vulkan_create_flat_texture().

The recovery path that can't be reached

vulkan_ensure_output_images() is written to survive a failed allocation: it clears the half-made images, returns false, and lets the next frame retry:

static bool vulkan_ensure_output_images()
{
	if ( !vulkan_defer_output_images() )
		return true;

	VulkanOutput_t *pOutput = &g_output;
	if ( !pOutput->outputImages.empty() && pOutput->outputImages[0] )
		return true;

	vk_log.debugf( "Making the shared output images on first use" );
	if ( vulkan_make_output_images( pOutput ) )
		return true;

	// A half-made set would pass the check above, so the next use tries again from nothing.
	pOutput->outputImages.clear();
	pOutput->outputImagesPartialOverlay.clear();
	return false;
}

But in deferred mode (nested Wayland) that path is unreachable, because vulkan_make_output_images() calls vulkan_create_debug_blank_texture() before it can return false, and that ends in an unconditional assert():

	// Oh no.
	pOutput->temporaryHackyBlankImage = vulkan_create_debug_blank_texture();
gamescope::OwningRc<CVulkanTexture> vulkan_create_flat_texture( uint32_t width, uint32_t height, uint8_t r, uint8_t g, uint8_t b, uint8_t a )
{
	...
	bool bRes = texture->BInit( width, height, 1u, VulkanFormatToDRM( VK_FORMAT_B8G8R8A8_UNORM ), flags );
	assert( bRes );

So a recoverable allocation failure, one the code two frames up explicitly expects and retries, takes down the whole compositor.

This is independent of what caused the allocation to fail. VK_ERROR_OUT_OF_DEVICE_MEMORY is a documented, recoverable result that this code path already knows how to retry, so the abort is gamescope's to fix regardless of why the allocation failed.

Two details make it more surprising than a plain assert:

  • The texture being allocated is vulkan_create_debug_blank_texture(), capped to 1920x1080 to match Steam's scaling. In this crash the three 3840x2160 output images allocated fine immediately beforehand, and then the ~8 MiB 1080p texture could not be allocated at all.
  • Because UsesVulkanSwapchain() is false here, the KMS-side retry loop at steamcompmgr.cpp:10423 (while ( !acquire_next_image() ) vulkan_remake_swapchain();) that provides equivalent resilience does not apply.

Would it be reasonable for vulkan_create_debug_blank_texture() to tolerate failure (return null and let vulkan_ensure_output_images() retry) rather than asserting? Happy to provide a patch if that is the preferred route.

Limits of this report

No core dump was available either; systemd-coredump reported Resource limits disable core dumping for process 14713 / Storage: none, so the line numbers above come from gamescope's own assertion output on 3.16.28, cross-checked against master.

SorenHJohansen avatar Oct 04 '26 19:10 SorenHJohansen

Same abort here on gamescope 3.16.31 (built from the tag with #2134 and #2251 applied, input-side only, #2251 with a 3-line local extension that also forwards the keyboard group, plus one extra log line of my own before vulkan_remake_output_images() to see which output-state check fired), nested Wayland on dwl / wlroots 0.19.3, NVIDIA RTX 3070 Ti 8 GB, driver 615.71.09 (nvidia-open). Game: RuneScape under Proton.

I can say what triggered it. The host compositor un-fullscreened the gamescope window (a screenshot tool's window mapped on the same workspace), so gamescope received a resize from 2560x1440 to 2558x1412 while the card was already at 7827 of 8192 MiB (sampled 14 s before the abort). For roughly a minute before that, the kernel had been logging nvidia-drm allocation failures (nvidia-drm ... Failed to allocate NVKMS memory for GEM object, tens of thousands of lines).

[gamescope] [Info]  xwm: Output state changed, remaking output images: size 2560x1440 -> 2558x1412, refresh 74925 -> 74925, rotation 0 -> 0, hdr 0 -> 0, hdr_capable 0 -> 0, hdr_force 0 -> 0   <- my local log line
[gamescope] [Error] vulkan: vkAllocateMemory failed (VkResult: -2)
gamescope: ../gamescope/src/rendervulkan.cpp:3170: gamescope::OwningRc<CVulkanTexture> vulkan_create_flat_texture(uint32_t, uint32_t, uint8_t, uint8_t, uint8_t, uint8_t): Assertion `bRes' failed.
[gamescopereaper] [Info]  reaper: Parent of gamescopereaper was killed. Killing children.

Coredump: SIGABRT in thread gamescope-xwm, frames resolved against the unstripped binary: vulkan_create_flat_texture <- vulkan_create_debug_blank_texture <- steamcompmgr_main, i.e. the vulkan_remake_output_images() path, same as yours. On the Wayland backend (UsesVulkanSwapchain() is false) that remake clears the old output images and the blank texture is its only allocation: min(output, 1920) x min(output, 1080) BGRA, about 8 MiB. The reaper then killed the game. Steam did not restart gamescope.

Steps to reproduce would be as follows:

  1. GPU memory full (the game held about 6 GB of 8, the rest of the desktop the remainder).
  2. Any output-size change.
  3. The ~8 MiB blank texture allocation fails and the assert aborts instead of reaching the retry path.

nilsenist avatar Oct 12 '26 20:10 nilsenist