sofa-pbrpc icon indicating copy to clipboard operation
sofa-pbrpc copied to clipboard

C++11编译运行Segmentation fault.

Open CaesarTang opened this issue 9 years ago • 7 comments

Hi,升级c++11以后,编译没问题,但是运行初始化client的时候会挂。

gdb如下:

Program terminated with signal 11, Segmentation fault. #0 signal_and_unlockboost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex > (this=0xd2ae4c80, lock=...) at thirdparty/boost/asio/detail/posix_event.hpp:60

60 signalled_ = true; Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.166.el6_7.3.x86_64 zlib-1.2.3-29.el6.x86_64

core文件bt如下: #0 signal_and_unlockboost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex > (this=0xd2ae4c80, lock=...) at thirdparty/boost/asio/detail/posix_event.hpp:60 #1 wake_one_idle_thread_and_unlock (this=0xd2ae4c80, lock=...) at thirdparty/boost/asio/detail/impl/task_io_service.ipp:484 #2 boost::asio::detail::task_io_service::wake_one_thread_and_unlock (this=0xd2ae4c80, lock=...) at thirdparty/boost/asio/detail/impl/task_io_service.ipp:493 #3 0x000000000054f32e in boost::asio::detail::task_io_service::init_task (this=0xd2ae4c80) at thirdparty/boost/asio/detail/impl/task_io_service.ipp:130 #4 0x0000000000552307 in init_task (this=0x2b0b918, io_service=Unhandled dwarf expression opcode 0xf3

) at thirdparty/boost/asio/detail/impl/epoll_reactor.ipp:145 #5 boost::asio::detail::deadline_timer_serviceboost::asio::time_traits<boost::posix_time::ptime >::deadline_timer_service (this=0x2b0b918, io_service=Unhandled dwarf expression opcode 0xf3

) at thirdparty/boost/asio/detail/deadline_timer_service.hpp:68 #6 0x00000000005523a6 in deadline_timer_service (owner=...) at thirdparty/boost/asio/deadline_timer_service.hpp:77 #7 boost::asio::detail::service_registry::create<boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traitsboost::posix_time::ptime > > (owner=...) at thirdparty/boost/asio/detail/impl/service_registry.hpp:81 #8 0x000000000054c4a6 in boost::asio::detail::service_registry::do_use_service (this=0xd2add000, key=..., factory=0x552350 <boost::asio::detail::service_registry::create<boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traitsboost::posix_time::ptime > >(boost::asio::io_service&)>)

at thirdparty/boost/asio/detail/impl/service_registry.ipp:123

#9 0x000000000055076e in use_service<boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traitsboost::posix_time::ptime > > (this=0x2b1aac8, io_service=Unhandled dwarf expression opcode 0xf3

) at thirdparty/boost/asio/detail/impl/service_registry.hpp:48 #10 use_service<boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traitsboost::posix_time::ptime > > (this=0x2b1aac8, io_service=Unhandled dwarf expression opcode 0xf3

) at thirdparty/boost/asio/impl/io_service.hpp:33 #11 boost::asio::basic_io_object<boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traitsboost::posix_time::ptime > >::basic_io_object (this=0x2b1aac8, io_service=Unhandled dwarf expression opcode 0xf3

) at thirdparty/boost/asio/basic_io_object.hpp:90 #12 0x0000000000707791 in basic_deadline_timer (this=0x2b1aa80, io_service=...) at thirdparty/boost/asio/basic_deadline_timer.hpp:149 #13 sofa::pbrpc::TimerWorker::TimerWorker (this=0x2b1aa80, io_service=...) at ./sofa/pbrpc/timer_worker.h:27 #14 0x00000000006fc16f in sofa::pbrpc::RpcClientImpl::Start (this=0x2b26c00) at sofa/pbrpc/rpc_client_impl.cc:88 #15 0x00000000006fad5c in sofa::pbrpc::RpcClient::RpcClient (this=0xd29f76a0, options=Unhandled dwarf expression opcode 0xf3

) at sofa/pbrpc/rpc_client.cc:16 #16 0x000000000053dc6d in XXXX::XXXX::SofaClientInit (this=0x2b68000) at xxx/xxx/xxxx/XXXCore.cpp:347

f 16如下:

client_options_ = (new sofa::pbrpc::RpcClientOptions()); 345 client_options_->work_thread_num = work_thread_num; 346 client_options_->callback_thread_num = callback_thread_num; 347 rpc_client_ = (new sofa::pbrpc::RpcClient(*client_options_)); 348 sofa_client_ = (new sofa::client::SofaClient<XXX_Stub>()); 349 sofa_client_->Init(rpc_client_,ip_list_str);

错误出现在347行

请问这是已知错误吗?有解决方案吗?

CaesarTang avatar Jan 22 '16 04:01 CaesarTang

@CaesarTang 是用-std=c++11编译的?

cyshi avatar Jan 22 '16 05:01 cyshi

对的,如果去掉这个参数就不会有问题

CaesarTang avatar Jan 22 '16 06:01 CaesarTang

我本地没有复现出来

g++版本

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)

boost 版本 1.59.0

内核版本

3.13.0-27-generic #50-Ubuntu SMP Thu May 15 18:06:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

cyshi avatar Jan 22 '16 07:01 cyshi

g++版本

`使用内建 specs。 COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.4/lto-wrapper 目标:x86_64-unknown-linux-gnu 配置为:../gcc-4.7.4/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib 线程模型:posix gcc 版本 4.7.4 (GCC)

boost 版本1.55

内核版本 Linux version 2.6.32-431.20.3.el6.mt20140703.x86_64 (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Thu Jul 3 16:57:03 CST 2014

LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.5 (Final) Release: 6.5 Codename: Final`

CaesarTang avatar Jan 22 '16 07:01 CaesarTang

Hi,上次提到的升级至C++11(4.7.4)以后可以编译,但是运行会core的问题,我再次升级至4.9.2,则不会出现上述问题请问有测试过4.7.4的编译器吗?

gcc -v

使用内建 specs。 COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/gcc-4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper 目标:x86_64-unknown-linux-gnu 配置为:../gcc-4.9.2/configure --prefix=/usr/local/gcc-4.9.2 --enable-checking=release --enable-languages=c,c++ --disable-multilib 线程模型:posix gcc 版本 4.9.2 (GCC)

CaesarTang avatar Apr 07 '16 05:04 CaesarTang

sorry 目前我们的测试没有覆盖到各个版本的编译器

cyshi avatar Apr 07 '16 05:04 cyshi

某个编译器编出来会core是不是暗示了代码有bug? @cyshi 用这个版本编译器试下,确认下是不是代码bug吧

bluebore avatar Apr 07 '16 12:04 bluebore