parlib: Prevent running ctors twice Previously, we only were protecting vcore_lib_init() and uthread_lib_init(). However, there are other ctors out there, some of which have external effects (devalarm). Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/user/parlib/alarm.c b/user/parlib/alarm.c index 00d7eea..54eaad4 100644 --- a/user/parlib/alarm.c +++ b/user/parlib/alarm.c
@@ -153,6 +153,8 @@ struct event_queue *ev_q; static struct fork_cb devalarm_fork_cb = {.func = devalarm_forked}; + if (__in_fake_parlib()) + return; /* Sets up timer chain (only one chain per process) */ spin_pdr_init(&global_tchain.lock); TAILQ_INIT(&global_tchain.waiters);
diff --git a/user/parlib/panic.c b/user/parlib/panic.c index ecac76c..dc796f5 100644 --- a/user/parlib/panic.c +++ b/user/parlib/panic.c
@@ -7,6 +7,8 @@ static void __attribute__((constructor)) parlib_stdio_init(void) { + if (__in_fake_parlib()) + return; /* This isn't ideal, since it might affect some stdout streams where our * parent tried to do something else. Note that isatty() always returns * TRUE, due to how we fake tcgetattr(), and that doesn't affect whatever
diff --git a/user/parlib/vcore_tick.c b/user/parlib/vcore_tick.c index d19ab95..fcd9e1d 100644 --- a/user/parlib/vcore_tick.c +++ b/user/parlib/vcore_tick.c
@@ -35,6 +35,8 @@ static void __attribute__((constructor)) vcore_tick_lib_init(void) { + if (__in_fake_parlib()) + return; __vc_ticks = calloc(max_vcores(), sizeof(struct vcore_tick)); assert(__vc_ticks); }