From 9fb7589fb5ca875a4bc2b4d6587eafcf85acf7f2 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 19 Apr 2023 14:08:41 +0800 Subject: [PATCH] fix(os): fix a deadlock. --- source/os/src/osSocket.c | 4 ++-- source/util/src/tlog.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 7d2c8aa4e5..2b2a0daf7b 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -1008,7 +1008,7 @@ int32_t taosGetFqdn(char *fqdn) { // hints.ai_family = AF_INET; strcpy(fqdn, hostname); strcpy(fqdn + strlen(hostname), ".local"); -#else // __APPLE__ +#else // linux struct addrinfo hints = {0}; struct addrinfo *result = NULL; hints.ai_flags = AI_CANONNAME; @@ -1020,7 +1020,7 @@ int32_t taosGetFqdn(char *fqdn) { } strcpy(fqdn, result->ai_canonname); freeaddrinfo(result); -#endif // __APPLE__ +#endif // linux return 0; } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index a3d3c399ab..e1cf01aa2f 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -791,8 +791,10 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t tjsonAddIntegerToObject(pJson, "clusterId", clusterId); tjsonAddIntegerToObject(pJson, "startTime", startTime); - taosGetFqdn(tmp); - tjsonAddStringToObject(pJson, "fqdn", tmp); + // Do NOT invoke the taosGetFqdn here. + // this function may be invoked when memory exception occurs,so we should assume that it is running in a memory locked + // environment. The lock operation by taosGetFqdn may cause this program deadlock. + tjsonAddStringToObject(pJson, "fqdn", tsLocalFqdn); tjsonAddIntegerToObject(pJson, "pid", taosGetPId()); -- GitLab