Fix EXC_GUARD crash: avoid closing Tor-owned fd on tor exit\n\nCTorHost: stop calling close(owning_fd_tor) in tor_thread_main. Tor already\ncloses its end; closing a reused guarded fd can trigger EXC_GUARD on iOS 18.\nWe now treat it as Tor-owned and just invalidate our reference.

This commit is contained in:
jack
2025-09-13 21:09:23 +02:00
parent b0a50c663f
commit 57cc9028cb
+5 -1
View File
@@ -40,7 +40,11 @@ static void *tor_thread_main(void *arg) {
int rc = tor_run_main(cfg); // blocks until tor exits int rc = tor_run_main(cfg); // blocks until tor exits
tor_main_configuration_free(cfg); tor_main_configuration_free(cfg);
if (argv_owned) { free(argv_owned); argv_owned = NULL; argv_owned_argc = 0; } if (argv_owned) { free(argv_owned); argv_owned = NULL; argv_owned_argc = 0; }
if (owning_fd_tor != -1) { close(owning_fd_tor); owning_fd_tor = -1; } // Do not close owning_fd_tor here: Tor may have already closed it and the
// fd number could have been re-used by the time we get here. On iOS 18,
// attempting to close a re-used guarded fd can trigger EXC_GUARD. Treat the
// tor-side end as owned by Tor and simply forget our reference.
owning_fd_tor = -1;
return (void*)(intptr_t)rc; return (void*)(intptr_t)rc;
} }