diff mbox series

[meta-oe] poco: Fix data race when create POSIX thread

Message ID 20231011182158.2236069-1-raj.khem@gmail.com
State New
Headers show
Series [meta-oe] poco: Fix data race when create POSIX thread | expand

Commit Message

Khem Raj Oct. 11, 2023, 6:21 p.m. UTC
This back fixes the ptest failures seen with musl

     AssertionError:-
     Failed ptests:
     {'poco': ['Foundation-testrunner', 'NetSSL-testrunner', 'Net-testrunner']}

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...x-data-race-when-create-POSIX-thread.patch | 33 +++++++++++++++++++
 meta-oe/recipes-support/poco/poco_1.12.4.bb   |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 meta-oe/recipes-support/poco/poco/0001-Fix-data-race-when-create-POSIX-thread.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/poco/poco/0001-Fix-data-race-when-create-POSIX-thread.patch b/meta-oe/recipes-support/poco/poco/0001-Fix-data-race-when-create-POSIX-thread.patch
new file mode 100644
index 0000000000..1a7f4dcdca
--- /dev/null
+++ b/meta-oe/recipes-support/poco/poco/0001-Fix-data-race-when-create-POSIX-thread.patch
@@ -0,0 +1,33 @@ 
+From 03b68fc924b24e12c87512d790d37fc6ddc352ac Mon Sep 17 00:00:00 2001
+From: Dawid Drozd <drozddawid@gmail.com>
+Date: Sat, 11 Feb 2023 14:48:39 +0400
+Subject: [PATCH] Fix data race when create POSIX thread
+
+When creating thread using pthread_create() `_pData->thread` will be set.
+It could lead to data race as in runnableEntry() we refer to that variable.
+
+Instead use pthread_self().
+getName() is already under mutex.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Backport [https://github.com/pocoproject/poco/pull/3942/commits/9c8a79b994a367f626c5551e0f38c27d0d8431f1]
+---
+ Foundation/src/Thread_POSIX.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Foundation/src/Thread_POSIX.cpp b/Foundation/src/Thread_POSIX.cpp
+index ceab76e82..3e52cd31f 100644
+--- a/Foundation/src/Thread_POSIX.cpp
++++ b/Foundation/src/Thread_POSIX.cpp
+@@ -351,7 +351,7 @@ void* ThreadImpl::runnableEntry(void* pThread)
+ #endif
+ 
+ 	ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
+-	setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName());
++	setThreadName(pthread_self(), reinterpret_cast<Thread*>(pThread)->getName());
+ 	AutoPtr<ThreadData> pData = pThreadImpl->_pData;
+ 	try
+ 	{
+-- 
+2.42.0
+
diff --git a/meta-oe/recipes-support/poco/poco_1.12.4.bb b/meta-oe/recipes-support/poco/poco_1.12.4.bb
index 8505f66e8b..12532e4ef1 100644
--- a/meta-oe/recipes-support/poco/poco_1.12.4.bb
+++ b/meta-oe/recipes-support/poco/poco_1.12.4.bb
@@ -11,6 +11,7 @@  DEPENDS = "libpcre2 zlib"
 SRC_URI = "git://github.com/pocoproject/poco.git;branch=master;protocol=https \
            file://0001-Use-std-atomic-int-instead-of-std-atomic-bool.patch \
            file://0001-cppignore.lnx-Ignore-PKCS12-and-testLaunch-test.patch \
+           file://0001-Fix-data-race-when-create-POSIX-thread.patch \
            file://run-ptest \
            "
 SRCREV = "1211613642269b7d53bea58b02de7fcd25ece3b9"