Skip to content

Conversation

@purplesyringa
Copy link
Contributor

Error::new allocates memory (see rust-lang/rust#148971). This is bad in multi-threaded programs, which microsandbox AFAIK is. If the fork occurs while the allocator lock is held by another thread, deadlocks can occur, since there's no one left in the new process to unlock the mutex. I do not believe this is UB, and modern libc offer protections against this issue, but this isn't POSIX-compliant and should preferably be avoided.

I've found two other places where setsid are invoked, and there it's called through libc, ignoring the resulting error (which should be impossible in a new process anyway). I adjusted the third place to use the same pattern.

@appcypher
Copy link
Member

@purplesyringa Can you extend ur fix to these lines as well:

command.pre_exec(|| {
nix::unistd::setsid()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;

@purplesyringa
Copy link
Contributor Author

Isn't that the exact same location?

@appcypher
Copy link
Member

you are right.

@appcypher appcypher merged commit c33b744 into zerocore-ai:main Nov 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants