Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2019-11-25 08:13:38 +0000
committerHenrik Rentz-Reichert2019-11-25 15:45:32 +0000
commit22b5b0f62d18b190474feee268a2119134fff344 (patch)
tree7cdc22b7b2d9c5482325a89ec5b0887efe4428e9 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent575610044f25e682bdac0554831c1ba005fa8fd6 (diff)
downloadorg.eclipse.etrice-22b5b0f62d18b190474feee268a2119134fff344.tar.gz
org.eclipse.etrice-22b5b0f62d18b190474feee268a2119134fff344.tar.xz
org.eclipse.etrice-22b5b0f62d18b190474feee268a2119134fff344.zip
Bug 552836 Race condition in shutdown sequence of Runner causes SEGV
Destroying the thread in etMessageService_destroy() Change-Id: Icee3faab3bf21acc50545274b2b74d41648a7a9c
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c2
3 files changed, 14 insertions, 2 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
index 7e72f428a..bcab9a989 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
@@ -31,8 +31,9 @@
#include <unistd.h>
#include <signal.h>
#if __GNUC__ <= 4
- /* in newer versions this header isn't needed explicitly */
#include <bits/siginfo.h>
+#else
+ #include <bits/types/sigevent_t.h>
#endif
#include <time.h>
#include <stdio.h>
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
index 383a52f4e..fecbae4ad 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
@@ -46,6 +46,7 @@ void etThread_construct(
self->threadName = threadName;
self->threadFunction = threadFunction;
self->threadFunctionData = threadFunctionData;
+ self->started = ET_FALSE;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -79,6 +80,9 @@ void etThread_start(etThread* self) {
void* etThread_execute(etThread* self){
ET_MSC_LOGGER_SYNC_ENTRY("etThread", "execute")
+ self->started = ET_TRUE;
+ /* set cancel state, thread must not change to PTHREAD_CANCEL_DISABLE */
+ pthread_setcancelstate(PTHREAD_CANCEL_DEFERRED, NULL);
/* etThread_execute redirects the call from the thread to the execute function in the eTrice runtime to enable correct synchronous MSC logging */
self->threadFunction(self->threadFunctionData);
ET_MSC_LOGGER_SYNC_EXIT
@@ -87,7 +91,12 @@ void* etThread_execute(etThread* self){
void etThread_destruct(etThread* self){
ET_MSC_LOGGER_SYNC_ENTRY("etThread", "destruct")
- pthread_detach(self->osData);
+ if (self->started) {
+ self->started = ET_FALSE;
+ /* Note: thread must not be in state PTHREAD_CANCEL_DISABLE */
+ pthread_cancel(self->osData);
+ pthread_join(self->osData, NULL);
+ }
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
index 9d7dc6661..f93be3aa9 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
@@ -43,6 +43,7 @@ void etThread_construct(
self->threadName = threadName;
self->threadFunction = threadFunction;
self->threadFunctionData = threadFunctionData;
+ self->started = ET_FALSE;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -56,6 +57,7 @@ void etThread_start(etThread* self) {
void etThread_execute(etThread* self){
ET_MSC_LOGGER_SYNC_ENTRY("etThread", "execute")
+ self->started = ET_TRUE;
/* etThread_execute redirects the call from the thread to the execute function in the eTrice runtime to enable correct synchronous MSC logging */
self->threadFunction(self->threadFunctionData);
ET_MSC_LOGGER_SYNC_EXIT

Back to the top