summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Gatien-Baron <valentin.gatienbaron@gmail.com>2021-08-01 08:41:17 -0400
committerValentin Gatien-Baron <valentin.gatienbaron@gmail.com>2021-08-01 08:41:17 -0400
commite26859e5ca10b669faf357b576f8a9f2300619d8 (patch)
tree0512ea3aebc4a64f13b7dfab74a150796dd79531
parent3155e0ee383d09c2003304f64c64c2376de3f192 (diff)
downloadlibfaketime-e26859e5ca10b669faf357b576f8a9f2300619d8.tar.gz
add a build variable to opt-out of some behaviors
Specifically behaviors that increase the chance that a wrapped program will not behave like an unwrapped program does, thus causing reliability issues.
-rw-r--r--src/Makefile11
-rw-r--r--src/libfaketime.c7
2 files changed, 18 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
index 15e1c68..c1b890d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -56,6 +56,17 @@
# -Dvariadic_promotion_t=int into CFLAGS). See src/faketime_common.h for
# more info.
#
+# FAKE_STATELESS
+# - Remove support for any functionality that requires sharing state across
+# threads of a process, or different processes. This decreases the risk of
+# interference with a program's normal execution, at the cost of supporting
+# fewer ways of specifying the time.
+# Concretely, this currently:
+# - disables PTHREAD_SINGLETHREADED_TIME, which can cause deadlocks in
+# multithreaded programs that fork due to making clock_gettime not
+# async-signal-safe
+# - disables all shared-memory across processes
+#
# FORCE_MONOTONIC_FIX
# - If the test program hangs forever on
# " pthread_cond_timedwait: CLOCK_MONOTONIC test
diff --git a/src/libfaketime.c b/src/libfaketime.c
index afafc5d..6def8f2 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -60,6 +60,9 @@
#include "time_ops.h"
#include "faketime_common.h"
+#if defined PTHREAD_SINGLETHREADED_TIME && defined FAKE_STATELESS
+#undef PTHREAD_SINGLETHREADED_TIME
+#endif
/* pthread-handling contributed by David North, TDI in version 0.7 */
#if defined PTHREAD_SINGLETHREADED_TIME || defined FAKE_PTHREAD
@@ -2652,7 +2655,11 @@ static void ftpl_init(void)
initialized = 1;
+#ifdef FAKE_STATELESS
+ if (0) ft_shm_init();
+#else
ft_shm_init();
+#endif
#ifdef FAKE_STAT
if (getenv("NO_FAKE_STAT")!=NULL)
{