[pypy-commit] stmgc default: Fix the test (don't expect variables like 'arg' to remain sensible
arigo
noreply at buildbot.pypy.org
Sat Mar 22 20:43:57 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1085:a33130d9f35c
Date: 2014-03-22 20:42 +0100
http://bitbucket.org/pypy/stmgc/changeset/a33130d9f35c/
Log: Fix the test (don't expect variables like 'arg' to remain sensible
across a setjmp! They need to be volatile)
diff --git a/c7/demo/demo_random.c b/c7/demo/demo_random.c
--- a/c7/demo/demo_random.c
+++ b/c7/demo/demo_random.c
@@ -288,11 +288,12 @@
stm_become_inevitable("please");
pop_roots();
return NULL;
- } else if (get_rand(360) == 1) {
- fprintf(stdout, "GUT");
+ } else if (get_rand(240) == 1) {
push_roots();
stm_become_globally_unique_transaction("really");
+ fprintf(stderr, "[GUT/%d]", (int)STM_SEGMENT->segment_num);
pop_roots();
+ return NULL;
}
return p;
}
@@ -324,8 +325,9 @@
setup_thread();
- objptr_t p = NULL;
+ objptr_t p;
stm_jmpbuf_t here;
+ volatile int call_fork = (arg != NULL);
STM_START_TRANSACTION(&stm_thread_local, here);
assert(td.num_roots >= td.num_roots_at_transaction_start);
@@ -345,7 +347,7 @@
if (p == (objptr_t)-1) {
push_roots();
- if (arg == NULL) { /* common case */
+ if (call_fork == 0) { /* common case */
stm_commit_transaction();
td.num_roots_at_transaction_start = td.num_roots;
if (get_rand(100) < 98) {
@@ -361,7 +363,7 @@
else {
/* run a fork() inside the transaction */
printf("========== FORK =========\n");
- arg = NULL;
+ call_fork = 0;
pid_t child = fork();
printf("=== in process %d thread %lx, fork() returned %d\n",
(int)getpid(), (long)pthread_self(), (int)child);
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -191,9 +191,9 @@
STM_PSEGMENT->shadowstack_at_start_of_transaction = tl->shadowstack;
STM_PSEGMENT->threadlocal_at_start_of_transaction = tl->thread_local_obj;
+ enter_safe_point_if_requested();
dprintf(("start_transaction\n"));
- enter_safe_point_if_requested();
s_mutex_unlock();
/* Now running the SP_RUNNING start. We can set our
More information about the pypy-commit
mailing list