Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1832:7a87c63be4d2
Date: 2015-06-14 18:18 +0200
http://bitbucket.org/pypy/stmgc/changeset/7a87c63be4d2/
Log: This should be a no-op unless I'm missing something.
diff --git a/c8/stm/detach.c b/c8/stm/detach.c
--- a/c8/stm/detach.c
+++ b/c8/stm/detach.c
@@ -82,10 +82,23 @@
_core_commit_transaction(/*external=*/ true);
}
-void _stm_reattach_transaction(stm_thread_local_t *tl)
+void _stm_reattach_transaction(intptr_t self)
{
intptr_t old;
int saved_errno = errno;
+ stm_thread_local_t *tl = (stm_thread_local_t *)self;
+
+ /* if 'self_or_0_if_atomic == 0', it means that we are trying to
+ reattach in a thread that is currently running a transaction
+ that is atomic. That should only be possible if we're
+ inevitable too. And in that case,
+ '_stm_detached_inevitable_from_thread' must always be 0, and
+ the previous call to compare_and_swap(0, 0) should have worked
+ (and done nothing), so we should not end here.
+ */
+ if (self == 0)
+ stm_fatalerror("atomic inconsistency");
+
restart:
old = _stm_detached_inevitable_from_thread;
if (old != 0) {
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -93,7 +93,7 @@
assert(_stm_detached_inevitable_from_thread == 0); \
_stm_detached_inevitable_from_thread = tl->self_or_0_if_atomic; \
} while (0)
-void _stm_reattach_transaction(stm_thread_local_t *tl);
+void _stm_reattach_transaction(intptr_t);
void _stm_become_inevitable(const char*);
void _stm_collectable_safe_point(void);
@@ -427,14 +427,15 @@
#include <stdio.h>
#endif
static inline void stm_enter_transactional_zone(stm_thread_local_t *tl) {
+ intptr_t self = tl->self_or_0_if_atomic;
if (__sync_bool_compare_and_swap(&_stm_detached_inevitable_from_thread,
- tl->self_or_0_if_atomic, 0)) {
+ self, 0)) {
#ifdef STM_DEBUGPRINT
fprintf(stderr, "stm_enter_transactional_zone fast path\n");
#endif
}
else {
- _stm_reattach_transaction(tl);
+ _stm_reattach_transaction(self);
/* _stm_detached_inevitable_from_thread should be 0 here, but
it can already have been changed from a parallel thread
(assuming we're not inevitable ourselves) */
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit