From 3d83a220384c4ec27018c0638bbf5a8f72a68ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Sat, 21 Jun 2025 10:43:33 +0800 Subject: [PATCH 1/8] =?UTF-8?q?tsan=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index c0588a3d..2286c2cb 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -46,11 +46,34 @@ static const EnvConfig g_configTable[] = { { APP_FLAGS_UBSAN_ENABLED, NULL, NULL, NULL, UBSAN_OPTIONS, NULL }, }; +bool isInRenderProcess(const AppSpawningCtx *property) +{ + static bool isRender = false; + static bool firstIn = true; + if (!firstIn) { + return isRender; + } + firstIn = false; + char *processType = (char *)GetAppPropertyExt(property, "ProcessType", NULL); + if (!processType) { + APPSPAWN_LOGE("GetAppPropertyExt ProcessType is null"); + return false; + } + if (strcmp(processType, "render") == 0 || strcmp(processType, "gpu") == 0) { + isRender = true; + } + return isRender; +} + static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *property) { size_t configTableSize = sizeof(g_configTable) / sizeof(g_configTable[0]); for (size_t i = 0; i < configTableSize; ++i) { if (CheckAppMsgFlagsSet(property, g_configTable[i].flag)) { + if (g_configTable[i].flag == APP_FLAGS_TSAN_ENABLED && isInRenderProcess(property)) { + APPSPAWN_LOGI("SetAsanEnabledEnv ship tsan setting if render process"); + continue; + } if (g_configTable[i].ldPreload) { setenv("LD_PRELOAD", g_configTable[i].ldPreload, 1); } -- Gitee From 3964dbf4d6b63ccb8c7e654565e87ca7ecfdbffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Thu, 26 Jun 2025 10:52:41 +0800 Subject: [PATCH 2/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index 2286c2cb..faf93038 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -71,7 +71,7 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p for (size_t i = 0; i < configTableSize; ++i) { if (CheckAppMsgFlagsSet(property, g_configTable[i].flag)) { if (g_configTable[i].flag == APP_FLAGS_TSAN_ENABLED && isInRenderProcess(property)) { - APPSPAWN_LOGI("SetAsanEnabledEnv ship tsan setting if render process"); + APPSPAWN_LOGI("SetAsanEnabledEnv skip tsan setting if render process"); continue; } if (g_configTable[i].ldPreload) { -- Gitee From e9d9595e1e85d00336654092116064a072283c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 10:12:19 +0800 Subject: [PATCH 3/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 72 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index faf93038..f42954f3 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -46,7 +46,7 @@ static const EnvConfig g_configTable[] = { { APP_FLAGS_UBSAN_ENABLED, NULL, NULL, NULL, UBSAN_OPTIONS, NULL }, }; -bool isInRenderProcess(const AppSpawningCtx *property) +static bool IsInRenderProcess(const AppSpawningCtx *property) { static bool isRender = false; static bool firstIn = true; @@ -54,8 +54,8 @@ bool isInRenderProcess(const AppSpawningCtx *property) return isRender; } firstIn = false; - char *processType = (char *)GetAppPropertyExt(property, "ProcessType", NULL); - if (!processType) { + char *processType = (char *)GetAppPropertyExt(property, MSG_EXT_NAME_PROCESS_TYPE, NULL); + if (processType == nullptr) { APPSPAWN_LOGE("GetAppPropertyExt ProcessType is null"); return false; } @@ -69,39 +69,41 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p { size_t configTableSize = sizeof(g_configTable) / sizeof(g_configTable[0]); for (size_t i = 0; i < configTableSize; ++i) { - if (CheckAppMsgFlagsSet(property, g_configTable[i].flag)) { - if (g_configTable[i].flag == APP_FLAGS_TSAN_ENABLED && isInRenderProcess(property)) { - APPSPAWN_LOGI("SetAsanEnabledEnv skip tsan setting if render process"); - continue; - } - if (g_configTable[i].ldPreload) { - setenv("LD_PRELOAD", g_configTable[i].ldPreload, 1); - } - if (g_configTable[i].asanOptions) { - setenv("ASAN_OPTIONS", g_configTable[i].asanOptions, 1); - } else { - unsetenv("ASAN_OPTIONS"); - } - if (g_configTable[i].tsanOptions) { - setenv("TSAN_OPTIONS", g_configTable[i].tsanOptions, 1); - } else { - unsetenv("TSAN_OPTIONS"); - } - if (g_configTable[i].ubsanOptions) { - setenv("UBSAN_OPTIONS", g_configTable[i].ubsanOptions, 1); - } else { - unsetenv("UBSAN_OPTIONS"); - } - if (g_configTable[i].hwasanOptions) { - setenv("HWASAN_OPTIONS", g_configTable[i].hwasanOptions, 1); - } else { - unsetenv("HWASAN_OPTIONS"); - } - APPSPAWN_LOGV("SetAsanEnabledEnv %{public}d,%{public}s,%{public}s,%{public}s,%{public}s,%{public}s", - g_configTable[i].flag, g_configTable[i].ldPreload, g_configTable[i].asanOptions, - g_configTable[i].tsanOptions, g_configTable[i].ubsanOptions, g_configTable[i].hwasanOptions); - return 0; + if (!CheckAppMsgFlagsSet(property, g_configTable[i].flag)) { + continue; } + if (g_configTable[i].flag == APP_FLAGS_TSAN_ENABLED && IsInRenderProcess(property)) { + APPSPAWN_LOGI("SetAsanEnabledEnv skip tsan setting if render process"); + continue; + } + if (g_configTable[i].ldPreload) { + setenv("LD_PRELOAD", g_configTable[i].ldPreload, 1); + } + if (g_configTable[i].asanOptions) { + setenv("ASAN_OPTIONS", g_configTable[i].asanOptions, 1); + } else { + unsetenv("ASAN_OPTIONS"); + } + if (g_configTable[i].tsanOptions) { + setenv("TSAN_OPTIONS", g_configTable[i].tsanOptions, 1); + } else { + unsetenv("TSAN_OPTIONS"); + } + if (g_configTable[i].ubsanOptions) { + setenv("UBSAN_OPTIONS", g_configTable[i].ubsanOptions, 1); + } else { + unsetenv("UBSAN_OPTIONS"); + } + if (g_configTable[i].hwasanOptions) { + setenv("HWASAN_OPTIONS", g_configTable[i].hwasanOptions, 1); + } else { + unsetenv("HWASAN_OPTIONS"); + } + APPSPAWN_LOGV("SetAsanEnabledEnv %{public}d,%{public}s,%{public}s,%{public}s,%{public}s,%{public}s", + g_configTable[i].flag, g_configTable[i].ldPreload, g_configTable[i].asanOptions, + g_configTable[i].tsanOptions, g_configTable[i].ubsanOptions, g_configTable[i].hwasanOptions); + return 0; + } return -1; } -- Gitee From 5c3cd74a976364dc6cd6fac62a9e7474f2f33eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 10:26:11 +0800 Subject: [PATCH 4/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index f42954f3..8ab326d3 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -55,7 +55,7 @@ static bool IsInRenderProcess(const AppSpawningCtx *property) } firstIn = false; char *processType = (char *)GetAppPropertyExt(property, MSG_EXT_NAME_PROCESS_TYPE, NULL); - if (processType == nullptr) { + if (processType == NULL) { APPSPAWN_LOGE("GetAppPropertyExt ProcessType is null"); return false; } -- Gitee From 44086bbe9fc2f782e8b4a19c32ecf5efc992896d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 11:10:40 +0800 Subject: [PATCH 5/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index 8ab326d3..5881606d 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -102,8 +102,7 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p APPSPAWN_LOGV("SetAsanEnabledEnv %{public}d,%{public}s,%{public}s,%{public}s,%{public}s,%{public}s", g_configTable[i].flag, g_configTable[i].ldPreload, g_configTable[i].asanOptions, g_configTable[i].tsanOptions, g_configTable[i].ubsanOptions, g_configTable[i].hwasanOptions); - return 0; - + return 0; } return -1; } -- Gitee From cc04599b2bb8361a3b8c3d117051a36dec75fc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 06:16:32 +0000 Subject: [PATCH 6/8] update modules/asan/asan_detector.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index 5881606d..1f5a0100 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -102,7 +102,7 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p APPSPAWN_LOGV("SetAsanEnabledEnv %{public}d,%{public}s,%{public}s,%{public}s,%{public}s,%{public}s", g_configTable[i].flag, g_configTable[i].ldPreload, g_configTable[i].asanOptions, g_configTable[i].tsanOptions, g_configTable[i].ubsanOptions, g_configTable[i].hwasanOptions); - return 0; + return 0; } return -1; } -- Gitee From 30dd30b62d211e13026d7e8a5f936f012a1a0b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 14:19:18 +0800 Subject: [PATCH 7/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index 5881606d..1f5a0100 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -102,7 +102,7 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p APPSPAWN_LOGV("SetAsanEnabledEnv %{public}d,%{public}s,%{public}s,%{public}s,%{public}s,%{public}s", g_configTable[i].flag, g_configTable[i].ldPreload, g_configTable[i].asanOptions, g_configTable[i].tsanOptions, g_configTable[i].ubsanOptions, g_configTable[i].hwasanOptions); - return 0; + return 0; } return -1; } -- Gitee From d221cb01c9afc721aeeda09acf466f6f4ddcae8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=85=B4=E5=87=AF?= Date: Fri, 27 Jun 2025 16:36:58 +0800 Subject: [PATCH 8/8] tsan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏兴凯 --- modules/asan/asan_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/asan/asan_detector.c b/modules/asan/asan_detector.c index 1f5a0100..52be5a68 100644 --- a/modules/asan/asan_detector.c +++ b/modules/asan/asan_detector.c @@ -69,7 +69,7 @@ static int SetAsanEnabledEnv(const AppSpawnMgr *content, const AppSpawningCtx *p { size_t configTableSize = sizeof(g_configTable) / sizeof(g_configTable[0]); for (size_t i = 0; i < configTableSize; ++i) { - if (!CheckAppMsgFlagsSet(property, g_configTable[i].flag)) { + if (CheckAppMsgFlagsSet(property, g_configTable[i].flag) == 0) { continue; } if (g_configTable[i].flag == APP_FLAGS_TSAN_ENABLED && IsInRenderProcess(property)) { -- Gitee