Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In a multi-threaded fork process, child processes may be stuck by locks #430

Open
zhixingchen0629 opened this issue Nov 28, 2024 · 0 comments

Comments

@zhixingchen0629
Copy link
Contributor

zhixingchen0629 commented Nov 28, 2024

system: Darwin Kernel Version 22.5.0

boost version: 1.85.0

When I use the process v2 version of the library to create child processes to perform tasks, when multiple threads create processes at the same time, there is a high probability that one of the processes will get stuck.

This is my experimental results chart:
Here we start 4 threads, and then each thread uses process v2 to create a child process at the same time.
Image

In this figure, process 37673 is blocked.
Running lldb, you can see that the call stack of process 37673 is as shown in the following figure. You can see that the process is waiting for a lock. From frame 9, it can be seen that the sub-process is stuck in the notify_fork operation, and the operation inside is stuck while obtaining the lock.

Image

Here is the stuck position, I try to add it before this sentence.
I try to manually release the lock here first, and this problem can be solved. The code is as follows:

 boost::asio::detail::signal_state *state = boost::asio::detail::get_signal_state();
 state->mutex_.unlock();

Image

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

No branches or pull requests

1 participant