You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/09/06 04:34:46 UTC

[GitHub] [incubator-brpc] wasphin opened a new issue #1227: Fork 子进程后死锁在 pthread_atfork

wasphin opened a new issue #1227:
URL: https://github.com/apache/incubator-brpc/issues/1227


   **Describe the bug (描述bug)**
   
   连接 ``brpc`` 库, 使用 [``boost::process``](https://www.boost.org/doc/libs/1_64_0/doc/html/process.html) 创建子进程, 子进程会在``create_sampling_thread`` 部分一直等下去.
   
   子进程逻辑目前与 brpc 无关.
   
   **To Reproduce (复现方法)**
   1. 连接 ``brpc`` 库, 使用 ``boost::process::child`` 启动子进程;
   
   **Expected behavior (期望行为)**
   
   可以顺利创建并启动子进程.
   
   **Versions (各种版本)**
   OS: RHEL8.2
   Compiler: g++ (GCC) 8.3.1 20191121
   brpc: 0.9.7
   protobuf: 3.5.0
   
   **Additional context/screenshots (更多上下文/截图)**
   
   ![Screenshot from 2020-09-06 12-33-24](https://user-images.githubusercontent.com/1237906/92318324-37ea6180-f03d-11ea-87b7-d2f6a0bcd137.png)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wasphin closed issue #1227: Fork 子进程后死锁在 pthread_atfork

Posted by GitBox <gi...@apache.org>.
wasphin closed issue #1227:
URL: https://github.com/apache/incubator-brpc/issues/1227


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wasphin commented on issue #1227: Fork 子进程后死锁在 pthread_atfork

Posted by GitBox <gi...@apache.org>.
wasphin commented on issue #1227:
URL: https://github.com/apache/incubator-brpc/issues/1227#issuecomment-687711837


   A reproducible example.
   
   file:  ``echo.cc``
   ```c++
   #include <boost/process.hpp>
   #include <iostream>
   
   int main(int, char*[]) {
       namespace bp = boost::process;
   
       bp::ipstream out;
       bp::child echo(bp::search_path("echo"), "hello, world!", bp::std_out > out);
   
       std::string line;
       while (out && std::getline(out, line) && !line.empty())
           std::cout << line << std::endl;
   
       echo.wait();
   
       return 0;
   }
   ```
   Without ``brpc``:
   ```
   $ g++ fork.cc -lboost_system -lboost_filesystem -pthread
   $ ./a.out 
   hello, world!
   ```
   With ``brpc``:
   ```
   $ g++ fork.cc -lbrpc -lboost_system -lboost_filesystem -pthread
   $ ldd a.out 
   	linux-vdso.so.1 (0x00007f2f8597b000)
   	libbrpc.so => /lib64/libbrpc.so (0x00007f2f84530000)
   	libboost_system.so.1.66.0 => /lib64/libboost_system.so.1.66.0 (0x00007f2f8432b000)
   	libboost_filesystem.so.1.66.0 => /lib64/libboost_filesystem.so.1.66.0 (0x00007f2f84110000)
   	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2f83d7b000)
   	libm.so.6 => /lib64/libm.so.6 (0x00007f2f839f9000)
   	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2f837e1000)
   	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2f835c1000)
   	libc.so.6 => /lib64/libc.so.6 (0x00007f2f831ff000)
   	libgflags.so.2.1 => /lib64/libgflags.so.2.1 (0x00007f2f82fd8000)
   	libprotobuf.so.15 => /lib64/libprotobuf.so.15 (0x00007f2f82adb000)
   	libleveldb.so.1 => /lib64/libleveldb.so.1 (0x00007f2f82877000)
   	libprotoc.so.15 => /lib64/libprotoc.so.15 (0x00007f2f823b9000)
   	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f2f81ed6000)
   	libdl.so.2 => /lib64/libdl.so.2 (0x00007f2f81cd2000)
   	libz.so.1 => /lib64/libz.so.1 (0x00007f2f81abb000)
   	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f2f81827000)
   	librt.so.1 => /lib64/librt.so.1 (0x00007f2f8161e000)
   	/lib64/ld-linux-x86-64.so.2 (0x00007f2f85755000)
   	libsnappy.so.1 => /lib64/libsnappy.so.1 (0x00007f2f81414000)
   $ ./a.out
   ```
   ```
   $ pgrep a.out
   28877
   28879
   $ pstack 28877
   Thread 2 (Thread 0x7fd3aa239700 (LWP 28878)):
   #0  0x00007fd3ac0ed238 in nanosleep () from /lib64/libc.so.6
   #1  0x00007fd3ac118d78 in usleep () from /lib64/libc.so.6
   #2  0x00007fd3ad53e322 in bvar::detail::SamplerCollector::run (this=0x1ac9600) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:174
   #3  0x00007fd3ad53ee29 in bvar::detail::SamplerCollector::sampling_thread (arg=<optimized out>) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:103
   #4  0x00007fd3ac3ef2de in start_thread () from /lib64/libpthread.so.0
   #5  0x00007fd3ac120e83 in clone () from /lib64/libc.so.6
   Thread 1 (Thread 0x7fd3ae76f9c0 (LWP 28877)):
   #0  0x00007fd3ac3f8b94 in read () from /lib64/libpthread.so.0
   #1  0x000000000041318c in boost::process::detail::posix::executor<boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<boost::fusion::tuple<boost::filesystem::path&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&> const, boost::process::detail::is_initializer<mpl_::arg<-1> > > > >::_read_error(int) ()
   #2  0x0000000000411a67 in boost::process::detail::posix::executor<boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<boost::fusion::tuple<boost::filesystem::path&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&> const, boost::process::detail::is_initializer<mpl_::arg<-1> > > > >::invoke(mpl_::bool_<false>, mpl_::bool_<false>) ()
   #3  0x000000000041025d in boost::process::detail::posix::executor<boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<boost::fusion::tuple<boost::filesystem::path&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&> const, boost::process::detail::is_initializer<mpl_::arg<-1> > > > >::operator()() ()
   #4  0x000000000040eb57 in boost::process::child boost::process::detail::basic_execute_impl<char, boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #5  0x000000000040cbd9 in boost::process::child boost::process::detail::execute_impl<boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #6  0x000000000040b1c8 in boost::process::child::child<boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #7  0x0000000000405a9f in main ()
   $ pstack 28879
   Thread 2 (Thread 0x7fd3aa239700 (LWP 28880)):
   #0  0x00007fd3ac0ed238 in nanosleep () from /lib64/libc.so.6
   #1  0x00007fd3ac118d78 in usleep () from /lib64/libc.so.6
   #2  0x00007fd3ad53e322 in bvar::detail::SamplerCollector::run (this=0x1ac9600) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:174
   #3  0x00007fd3ad53ee29 in bvar::detail::SamplerCollector::sampling_thread (arg=<optimized out>) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:103
   #4  0x00007fd3ac3ef2de in start_thread () from /lib64/libpthread.so.0
   #5  0x00007fd3ac120e83 in clone () from /lib64/libc.so.6
   Thread 1 (Thread 0x7fd3ae76f9c0 (LWP 28879)):
   #0  0x00007fd3ac12e58c in __lll_lock_wait_private () from /lib64/libc.so.6
   #1  0x00007fd3ac12e772 in __register_atfork () from /lib64/libc.so.6
   #2  0x00007fd3ad53ec17 in bvar::detail::SamplerCollector::create_sampling_thread (this=0x1ac9600) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:91
   #3  bvar::detail::SamplerCollector::after_forked_as_child (this=0x1ac9600) at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:97
   #4  bvar::detail::SamplerCollector::child_callback_atfork () at /usr/src/debug/brpc-0.9.7-1.el8.x86_64/src/bvar/detail/sampler.cpp:82
   #5  0x00007fd3ac12eb10 in __run_fork_handlers () from /lib64/libc.so.6
   #6  0x00007fd3ac0ed38c in fork () from /lib64/libc.so.6
   #7  0x00000000004117c9 in boost::process::detail::posix::executor<boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<boost::fusion::tuple<boost::filesystem::path&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&> const, boost::process::detail::is_initializer<mpl_::arg<-1> > > > >::invoke(mpl_::bool_<false>, mpl_::bool_<false>) ()
   #8  0x000000000041025d in boost::process::detail::posix::executor<boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<boost::fusion::tuple<boost::filesystem::path&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&> const, boost::process::detail::is_initializer<mpl_::arg<-1> > > > >::operator()() ()
   #9  0x000000000040eb57 in boost::process::child boost::process::detail::basic_execute_impl<char, boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #10 0x000000000040cbd9 in boost::process::child boost::process::detail::execute_impl<boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #11 0x000000000040b1c8 in boost::process::child::child<boost::filesystem::path, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1> >(boost::filesystem::path&&, char const (&) [14], boost::process::detail::posix::pipe_out<1, -1>&&) ()
   #12 0x0000000000405a9f in main ()
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wasphin commented on issue #1227: Fork 子进程后死锁在 pthread_atfork

Posted by GitBox <gi...@apache.org>.
wasphin commented on issue #1227:
URL: https://github.com/apache/incubator-brpc/issues/1227#issuecomment-687779766


   抱歉, 刚看到最新版本有修正.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org