Skip to content

server: release guard crash charge on stopped devices and clamp protectedMemory - #101

Open
ExecuteOrd66 wants to merge 2 commits into
ASEbrahim:rel/v0.5.5.4from
ExecuteOrd66:fix/guard-release-charge-on-stopped-device
Open

ExecuteOrd66 wants to merge 2 commits into
ASEbrahim:rel/v0.5.5.4from
ExecuteOrd66:fix/guard-release-charge-on-stopped-device

Conversation

@ExecuteOrd66

Copy link
Copy Markdown

Summary

Two correctness and stability fixes in the bridge server:

  1. Release crash-containment charge when stopped or retained devices are abandoned (server_guard.c, server_conn.c, server_instance.c)

    • server_guard.c charges each contained driver fault to its device (charged[t->id]) and subtracts it from process_crashes in vkb_guard_device_destroy(), so that PROCESS_MAX (64) limits faults from currently running programs rather than accumulating over the server's lifetime.
    • However, when a device is marked stopped after a contained driver fault (vkb_lost_stop) or kept alive due to an active sync-fd export (vkb_syncfd_device_destroy), the teardown paths in vkb_proc_cleanup(), vkb_srv_instance_orphans(), and vkb_sv_vkDestroyDevice() skip device_cleanup() / vkb_guard_device_destroy() so the unsafe device handle is never touched again.
    • Because of that early return / continue, charged[t->id] was never refunded when a short-lived faulting client exited, allowing repeated restarts to monotonically exhaust PROCESS_MAX and disable containment for the whole bridge server.
    • Fix: extract the idempotent atomic refund (__atomic_exchange_n(&charged[t->id], 0, __ATOMIC_RELAXED)) into vkb_guard_device_release_charge(vkb_srv_table *t) and invoke it on those early-return / continue paths (always outside tables_lock, without touching driver handles or freeing guard state) as well as from vkb_guard_device_destroy().
  2. Hide and clamp protectedMemory over the bridge (server_emu.c)

    • Protected memory / DRM queues are not used over the Vulkan bridge, and enabling VkPhysicalDeviceProtectedMemoryFeatures::protectedMemory (or VkPhysicalDeviceVulkan11Features::protectedMemory) in vkCreateDevice can cause mobile Vulkan drivers to fail to initialize or omit standard (flags = 0) queues, resulting in a NULL queue handle and SIGSEGV inside the Android Vulkan loader on vkGetDeviceQueue.
    • Fix: report protectedMemory = VK_FALSE in vkb_emu_report_features2() and clear it to VK_FALSE in vkb_emu_device_clamp_features() before vkCreateDevice reaches the driver.

Verification

  • Cross-compiled libvkbridge_server.so and libvkbridge_jni.so for arm64-v8a with Android NDK r27c (clean build, zero warnings).
  • Verified on-device: vkGetDeviceQueue faults drop to 0 and the bridge server stays alive without exhausting PROCESS_MAX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants