From 09730d8a1bfabc20eceee18f7d2d324bd72e9e38 Mon Sep 17 00:00:00 2001 From: Alexey Dulaev Date: Fri, 5 Oct 2018 11:26:39 +0300 Subject: [PATCH] Mitigate GRALLOC1_PFN_LOCK_FLEX multithread issue. lockFlex fills outFlexLayout->planes with pointer to global variable ycbcrplanes, doesn't work from multiple threads. Workaround: change the variable to thread_local. Jira: OAM-70143, MDP-51191 Test: check memory regions mapped from different threads don't overlap --- cros_gralloc/gralloc1/cros_gralloc1_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_gralloc/gralloc1/cros_gralloc1_module.cc b/cros_gralloc/gralloc1/cros_gralloc1_module.cc index d9136fa..566fd33 100644 --- a/cros_gralloc/gralloc1/cros_gralloc1_module.cc +++ b/cros_gralloc/gralloc1/cros_gralloc1_module.cc @@ -405,7 +405,7 @@ int32_t CrosGralloc1::lock(buffer_handle_t bufferHandle, gralloc1_producer_usage return CROS_GRALLOC_ERROR_NONE; } -android_flex_plane_t ycbcrplanes[3]; +thread_local android_flex_plane_t ycbcrplanes[3]; int32_t update_flex_layout(struct android_ycbcr *ycbcr, struct android_flex_layout *outFlexLayout) { -- 2.11.0