aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikodem Rabuliński <nikodem@rabulinski.com>2024-05-07 21:26:24 +0000
committerGerrit Code Review <gerrit@lix-systems>2024-05-07 21:26:24 +0000
commite8a603fb2f6418307c3521785b3c8d73396792d8 (patch)
treeb3f9f854b8bc48d0b89d4bab106be88320c6ef26 /src
parent964ac8b0e88fb5789b87e33273e42363958d0afb (diff)
parentf894cce79b05913891c8356948b5fc468a53c198 (diff)
Merge changes Icf26010a,Ib6161567 into main
* changes: Always initialize curl in parent process on darwin Fix failing darwin tests
Diffstat (limited to 'src')
-rw-r--r--src/libstore/globals.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index b7397da1a..3308cad1f 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -25,6 +25,7 @@
#include "config-impl.hh"
#ifdef __APPLE__
+#include <curl/curl.h>
#include <sys/sysctl.h>
#endif
@@ -409,10 +410,21 @@ void initLibStore() {
preloadNSS();
+#if __APPLE__
+ /* Because of an objc quirk[1], calling curl_global_init for the first time
+ after fork() will always result in a crash.
+ Up until now the solution has been to set OBJC_DISABLE_INITIALIZE_FORK_SAFETY
+ for every nix process to ignore that error.
+ Instead of working around that error we address it at the core -
+ by calling curl_global_init here, which should mean curl will already
+ have been initialized by the time we try to do so in a forked process.
+
+ [1] https://github.com/apple-oss-distributions/objc4/blob/01edf1705fbc3ff78a423cd21e03dfc21eb4d780/runtime/objc-initialize.mm#L614-L636
+ */
+ curl_global_init(CURL_GLOBAL_ALL);
/* On macOS, don't use the per-session TMPDIR (as set e.g. by
sshd). This breaks build users because they don't have access
to the TMPDIR, in particular in ‘nix-store --serve’. */
-#if __APPLE__
if (getEnv("TMPDIR").value_or("/tmp").starts_with("/var/folders/"))
unsetenv("TMPDIR");
#endif