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

基于 braft的程序一启动就core,麻烦帮看看 从哪里找找原因 #20

Closed
ghost opened this issue May 3, 2018 · 12 comments
Closed

Comments

@ghost
Copy link

ghost commented May 3, 2018

warning: core file may not match specified executable file.
[New LWP 12604]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./demo_server.bin'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f1d2ae23c16 in pthread_mutex_lock_impl (mutex=0x11dfdc0) at src/bthread/mutex.cpp:545
545 return sys_pthread_mutex_lock(mutex);
Missing separate debuginfos, use: debuginfo-install bzip2-libs-1.0.6-13.el7.x86_64 gflags-2.1.1-6.el7.x86_64 glibc-2.17-196.el7_4.2.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.13.2-12.el7_2.x86_64 leveldb-1.12.0-11.el7.x86_64 libcom_err-1.42.9-7.el7.x86_64 libgcc-4.8.5-4.el7.x86_64 libselinux-2.2.2-6.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 libuuid-2.23.2-26.el7_2.2.x86_64 openssl-libs-1.0.1e-51.el7_2.7.x86_64 pcre-8.32-15.el7_2.1.x86_64 protobuf-2.5.0-8.el7.x86_64 protobuf-compiler-2.5.0-8.el7.x86_64 snappy-1.1.0-3.el7.x86_64 xz-libs-5.1.2-12alpha.el7.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) where
#0 0x00007f1d2ae23c16 in pthread_mutex_lock_impl (mutex=0x11dfdc0) at src/bthread/mutex.cpp:545
#1 pthread_mutex_lock (__mutex=0x11dfdc0) at src/bthread/mutex.cpp:803

@jamesge
Copy link
Contributor

jamesge commented May 3, 2018

os和编译器分别是什么

@ghost
Copy link
Author

ghost commented May 3, 2018

centos 7 x86_64
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)

@jamesge
Copy link
Contributor

jamesge commented May 3, 2018

centos 7应该是支持的,检查下mutex的生命周期是否正确吧

@ghost
Copy link
Author

ghost commented May 3, 2018

debug试了下,进入main之前就core了,好奇怪,难道是编译的问题。。

@chenzhangyi
Copy link
Collaborator

贴一下完整的栈吧,编译brpc的时候也把debug_symbol打开.

@Edward-xk
Copy link
Collaborator

centos 7 x86_64, gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
这个版本的os和编译器检查过应该没有问题

@ghost
Copy link
Author

ghost commented May 3, 2018

我重新编译了一次,现在执行报这个错误
ERROR: something wrong with flag 'crash_on_fatal_log' in file 'src/butil/logging.cc'. One possibility: file 'src/butil/logging.cc' is being linked both statically and dynamically into this executable.

需要增加哪些编译选项

@ipconfigme
Copy link
Collaborator

看上去是编译的时候同时链接了静态库和动态库,这个是你的程序编译出错还是braft的demo出错?

@pdu
Copy link

pdu commented May 10, 2018

@wind-zhang 可以考虑用bazel.build来编译,非常方便。
可以参考这个rule:https://gist.github.com/pdu/60b143635435c591218113c93fb9ee7e

@ghost
Copy link
Author

ghost commented May 10, 2018

非常感谢各位的回复,我这边编译的时候是连接了动态库的,运行的时候报的,后面改为静态连接 运行就没问题了。
暂时还不明白为什么动态连接不行 ,按理说 不应该再连接brpc的源文件了
https://gist.github.com/pdu/60b143635435c591218113c93fb9ee7e 另外这个链接打不开哦

@jamesge
Copy link
Contributor

jamesge commented May 10, 2018

@wind-zhang 并不是动态链接不行,而是你同时链接了动态和静态链接库,全局变量是一套但会初始化两次,这个错误行为被gflags侦测到了(因为所有gflags都是全局变量,必须检查这点)
@pdu 考虑给braft提个支持bazel的PR?(而不是code snippet这种方式)

@pdu
Copy link

pdu commented May 11, 2018

@jamesge 好的,我整理一下。

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

5 participants