From 11d6125aa5948a065c4195defb3f5840a87d2a65 Mon Sep 17 00:00:00 2001 From: xieyijun3 Date: Sun, 29 Dec 2024 02:53:46 +0000 Subject: [PATCH 1/2] PA protection Signed-off-by: x30034819 Signed-off-by: xieyijun3 --- base/threading/platform_thread_posix.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 89ea7935b6..1f2ab0a9ab 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -127,6 +127,18 @@ bool CreateThread(size_t stack_size, DCHECK(thread_handle); base::InitThreading(); +#if BUILDFLAG(IS_OHOS) +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN) && BUILDFLAG(HAS_64_BIT_POINTERS) + // Ensure that PartitionAddressSpace::Init is executed on the main thread + // to avoid concurrency issues. + static bool partitionAddressSpaceInit = false; + if ((!partitionAddressSpaceInit) && (getpid() == getpid())) { + partition_alloc::internal::PartitionAddressSpace::Init(); + partitionAddressSpaceInit = true; + } +#endif +#endif + pthread_attr_t attributes; pthread_attr_init(&attributes); -- Gitee From fbc0da0bfe2cdd33dc9fb510f108f24eb715227b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=9B=8A=E5=90=9B?= Date: Mon, 30 Dec 2024 05:21:15 +0000 Subject: [PATCH 2/2] update base/threading/platform_thread_posix.cc. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢益君 --- base/threading/platform_thread_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 1f2ab0a9ab..76a57a31e7 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -132,7 +132,7 @@ bool CreateThread(size_t stack_size, // Ensure that PartitionAddressSpace::Init is executed on the main thread // to avoid concurrency issues. static bool partitionAddressSpaceInit = false; - if ((!partitionAddressSpaceInit) && (getpid() == getpid())) { + if ((!partitionAddressSpaceInit) && (getpid() == gettid())) { partition_alloc::internal::PartitionAddressSpace::Init(); partitionAddressSpaceInit = true; } -- Gitee