forked from lix-project/lix
Always initialize curl in parent process on darwin
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. This is less than ideal because we were setting it in package.nix, which meant that running nix tests locally would fail because that variable was not set. Instead of working around that error we address it at the core - by calling curl_global_init inside initLibStore, which should mean curl will already have been initialized by the time we try to do so in a forked process. [1]da82a83b15/runtime/objc-initialize.mm (L417-L439)
Change-Id:Icf26010a8be655127cc130efb9c77b603a6660d0
This commit is contained in:
parent
83a2cd0c46
commit
ed7d6e04b9
|
@ -2,11 +2,6 @@
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>EnvironmentVariables</key>
|
|
||||||
<dict>
|
|
||||||
<key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
|
|
||||||
<string>YES</string>
|
|
||||||
</dict>
|
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>org.nixos.nix-daemon</string>
|
<string>org.nixos.nix-daemon</string>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
|
|
|
@ -400,10 +400,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
mesonInstallCheckFlags = [ "--suite=installcheck" ];
|
mesonInstallCheckFlags = [ "--suite=installcheck" ];
|
||||||
|
|
||||||
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
||||||
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
|
||||||
'';
|
|
||||||
|
|
||||||
installCheckPhase = lib.optionalString buildWithMeson ''
|
installCheckPhase = lib.optionalString buildWithMeson ''
|
||||||
runHook preInstallCheck
|
runHook preInstallCheck
|
||||||
flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}")
|
flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}")
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "config-impl.hh"
|
#include "config-impl.hh"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#include <curl/curl.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -413,6 +414,7 @@ void initLibStore() {
|
||||||
sshd). This breaks build users because they don't have access
|
sshd). This breaks build users because they don't have access
|
||||||
to the TMPDIR, in particular in ‘nix-store --serve’. */
|
to the TMPDIR, in particular in ‘nix-store --serve’. */
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
if (getEnv("TMPDIR").value_or("/tmp").starts_with("/var/folders/"))
|
if (getEnv("TMPDIR").value_or("/tmp").starts_with("/var/folders/"))
|
||||||
unsetenv("TMPDIR");
|
unsetenv("TMPDIR");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue