summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-04-17 21:46:56 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-04-17 22:47:45 +0300
commitc482e0d5a94a316308f9a29bf0126d338ec5efe7 (patch)
tree4e1f89ab198eef8776ace94b8650bd459bad5217 /pthread_support.c
parent0077860118df1511ab5b2e653b90d3ace0b9e96a (diff)
downloadbdwgc-c482e0d5a94a316308f9a29bf0126d338ec5efe7.tar.gz
Workaround 'unreliable value of me after 2nd lock' code defect FP
(fix of commit 7f97528c5) * pthread_support.c [LINT2 && GC_ASSERTIONS] (GC_do_blocking_inner): Define saved_me local variable. * pthread_support.c [LINT2] (GC_do_blocking_inner): After the 2nd LOCK recompute "me" value and assert that it is the same as the previously computed one; add comment.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 1f32bc4d..3c5dcbbf 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -1592,6 +1592,21 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED)
d -> client_data = (d -> fn)(d -> client_data);
LOCK(); /* This will block if the world is stopped. */
+# ifdef LINT2
+ {
+# ifdef GC_ASSERTIONS
+ GC_thread saved_me = me;
+# endif
+
+ /* The pointer to the GC thread descriptor should not be */
+ /* changed while the thread is registered but a static */
+ /* analysis tool might complain that this pointer value */
+ /* (obtained in the first locked section) is unreliable in */
+ /* the second locked section. */
+ me = GC_lookup_thread(pthread_self());
+ GC_ASSERT(me == saved_me);
+ }
+# endif
# if defined(GC_ENABLE_SUSPEND_THREAD) && defined(SIGNAL_BASED_STOP_WORLD)
/* Note: this code cannot be moved into do_blocking_leave() */
/* otherwise there could be a static analysis tool warning */