Author: Armin Rigo <[email protected]>
Branch:
Changeset: r940:e6540f4d2a4b
Date: 2014-03-03 15:58 +0100
http://bitbucket.org/pypy/stmgc/changeset/e6540f4d2a4b/
Log: Baaah thanks Remi. Missing locks here.
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -84,6 +84,8 @@
{
/* This function is called during testing, but normal programs don't
need to call it. */
+ assert(!_has_mutex());
+
long i;
for (i = 0; i < NB_SEGMENTS; i++) {
struct stm_priv_segment_info_s *pr = get_priv_segment(i);
@@ -124,6 +126,7 @@
void stm_register_thread_local(stm_thread_local_t *tl)
{
int num;
+ s_mutex_lock();
if (stm_all_thread_locals == NULL) {
stm_all_thread_locals = tl->next = tl->prev = tl;
num = 0;
@@ -144,16 +147,19 @@
tl->associated_segment_num = num;
_init_shadow_stack(tl);
set_gs_register(get_segment_base(num));
+ s_mutex_unlock();
}
void stm_unregister_thread_local(stm_thread_local_t *tl)
{
+ s_mutex_lock();
assert(tl->next != NULL);
_done_shadow_stack(tl);
if (tl == stm_all_thread_locals) {
stm_all_thread_locals = stm_all_thread_locals->next;
if (tl == stm_all_thread_locals) {
stm_all_thread_locals = NULL;
+ s_mutex_unlock();
return;
}
}
@@ -161,6 +167,7 @@
tl->next->prev = tl->prev;
tl->prev = NULL;
tl->next = NULL;
+ s_mutex_unlock();
}
static bool _is_tl_registered(stm_thread_local_t *tl) __attribute__((unused));
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit