gfxstream: fix string array marshalling

This is a follow-up to:

   - commit e27e41a8 ("vulkan,spirv: update headers")
   - commit c4cecd9d ("gfxstream: cereal: fix 'None' in gfxstream codegen")

The second commit fixed compile, but still produced a
crash on the host side:

$0 __memcpy_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:833
$1 0x00007f116f8ee285 in memcpy (__dest=0x7f0d258cd340, __dest@entry=0x7f0ed55e9458, __src=0x7f0e78072ff7, __src@entry=0x72795f61, __len=1920556897)
   at prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/string3.h:51
$2 gfxstream::host::vk::VulkanStream::loadStringInPlaceWithStreamPtr (this=this@entry=0x7f0e78022b50, forOutput=forOutput@entry=0x7f0d97fff018,
   streamPtr=streamPtr@entry=0x7f0ed55e9458) at hardware/google/gfxstream/host/vulkan/vulkan_stream.cpp:100
$3 0x00007f116f8ee3de in gfxstream::host::vk::VulkanStream::loadStringArrayInPlaceWithStreamPtr (this=0x7f0e78022b50, forOutput=<optimized out>,
   streamPtr=0x7f0ed55e9458) at hardware/google/gfxstream/host/vulkan/vulkan_stream.cpp:122
$4 0x00007f116f9f2fcb in gfxstream::host::vk::reservedunmarshal_VkDeviceCreateInfo (vkStream=vkStream@entry=0x7f0e78022b50,

Fix up lenAccess string marshaling to prevent this.

TEST=launch_cvd --gpu_mode=gfxstream_guest_angle_host_swiftshader

Reviewed-by: David Gilhooley <djgilhooley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41059>
This commit is contained in:
Gurchetan Singh 2026-04-17 10:46:25 -07:00 committed by Marge Bot
parent 4c3e8fbc02
commit c6b3fc6930
2 changed files with 17 additions and 22 deletions

View file

@ -455,9 +455,8 @@ class VulkanMarshalingCodegen(VulkanTypeIterator):
lenAccess = self.lenAccessor(vulkanType)
if self.direction == "write":
if lenAccess is not None:
self.cgen.stmt("saveStringArray(%s, %s, %s)" % (self.streamVarName,
access, lenAccess))
self.cgen.stmt("saveStringArray(%s, %s, %s)" % (self.streamVarName,
access, lenAccess if lenAccess is not None else "0"))
else:
castExpr = \
self.makeCastExpr( \
@ -471,9 +470,7 @@ class VulkanMarshalingCodegen(VulkanTypeIterator):
lenAccess = self.lenAccessor(vulkanType)
if lenAccess is not None:
finalLenExpr = "%s * %s" % (lenAccess, self.cgen.sizeofExpr(vulkanType))
else:
finalLenExpr = self.cgen.sizeofExpr(vulkanType)
self.genStreamCall(vulkanType, access, finalLenExpr)
self.genStreamCall(vulkanType, access, finalLenExpr)
# Old version VkEncoder may have some sType values conflict with VkDecoder
# of new versions. For host decoder, it should not carry the incorrect old

View file

@ -548,26 +548,24 @@ class VulkanReservedMarshalingCodegen(VulkanTypeIterator):
lenAccessGuard = self.lenAccessorGuard(vulkanType)
if self.direction == "write":
self.cgen.beginBlock()
self.cgen.stmt("uint32_t c = 0")
if lenAccess is not None:
self.cgen.beginBlock()
self.cgen.stmt("uint32_t c = 0")
if lenAccessGuard is not None:
self.cgen.beginIf(lenAccessGuard)
self.cgen.beginIf(lenAccessGuard)
self.cgen.stmt("c = %s" % (lenAccess))
if lenAccessGuard is not None:
self.cgen.endIf()
self.genMemcpyAndIncr(self.ptrVar, "(uint32_t*)" ,"&c", "sizeof(uint32_t)", toBe = True, actualSize = 4)
self.cgen.beginFor("uint32_t i = 0", "i < c", "++i")
self.cgen.stmt("uint32_t l = %s ? strlen(%s[i]): 0" % (access, access))
self.genMemcpyAndIncr(self.ptrVar, "(uint32_t*)" ,"&l", "sizeof(uint32_t)", toBe = True, actualSize = 4)
self.cgen.beginIf("l")
self.genMemcpyAndIncr(self.ptrVar, "(char*)", "(%s[i])" % access, "l")
self.cgen.endIf()
self.cgen.endFor()
self.cgen.endBlock()
self.genMemcpyAndIncr(self.ptrVar, "(uint32_t*)" ,"&c", "sizeof(uint32_t)", toBe = True, actualSize = 4)
self.cgen.beginFor("uint32_t i = 0", "i < c", "++i")
self.cgen.stmt("uint32_t l = %s ? strlen(%s[i]): 0" % (access, access))
self.genMemcpyAndIncr(self.ptrVar, "(uint32_t*)" ,"&l", "sizeof(uint32_t)", toBe = True, actualSize = 4)
self.cgen.beginIf("l")
self.genMemcpyAndIncr(self.ptrVar, "(char*)", "(%s[i])" % access, "l")
self.cgen.endIf()
self.cgen.endFor()
self.cgen.endBlock()
else:
castExpr = \
self.makeCastExpr( \