GRPC服务器无法启动(问候服务器示例)

时间:2019-11-16 08:05:17

标签: c++ protocol-buffers grpc

根据安装文档(https://grpc.io/docs/quickstart/cpp/)安装了GRPC(C ++)。构建成功完成。但是,在构建并执行helloworld示例(examples/cpp/helloworld/)之后,greeter_server挂起。在下面登录:

GRPC_VERBOSITY=DEBUG ./greeter_server      
D1116 13:26:27.355365283    6807 ev_posix.cc:174]            Using polling engine: epollex
D1116 13:26:27.355788088    6807 dns_resolver_ares.cc:503]   Using ares dns resolver

预期的行为是greeter_client显示Greeter received: Hello world

使用调试信息进行构建之后,使用GDB运行并获取线程转储:

Thread 3 (Thread 0x7fffeffff700 (LWP 2561)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x55555559cef0) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x55555559ce90, cond=0x55555559cec8) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x55555559cec8, mutex=0x55555559ce90) at pthread_cond_wait.c:655
#3  0x00007ffff7daf392 in gpr_cv_wait () from /usr/local/lib/libgrpc.so.9
#4  0x00007ffff7f27930 in grpc_core::Executor::ThreadMain(void*) () from /usr/local/lib/libgrpc++.so.1
#5  0x00007ffff7db0ed3 in ?? () from /usr/local/lib/libgrpc.so.9
#6  0x00007ffff701cfa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#7  0x00007ffff71404cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7ffff6e81700 (LWP 2560)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x5555555a0e20) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555555a0dc0, cond=0x5555555a0df8) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5555555a0df8, mutex=0x5555555a0dc0) at pthread_cond_wait.c:655
#3  0x00007ffff7daf392 in gpr_cv_wait () from /usr/local/lib/libgrpc.so.9
#4  0x00007ffff7f27930 in grpc_core::Executor::ThreadMain(void*) () from /usr/local/lib/libgrpc++.so.1
#5  0x00007ffff7db0ed3 in ?? () from /usr/local/lib/libgrpc.so.9
#6  0x00007ffff701cfa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#7  0x00007ffff71404cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7ffff6e84cc0 (LWP 2554)):
#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:737
#1  0x00007ffff7f5aaac in grpc_core::TraceFlagList::Set(char const*, bool) () from /usr/local/lib/libgrpc++.so.1
#2  0x00007ffff7f5abbe in grpc_tracer_init() () from /usr/local/lib/libgrpc++.so.1
#3  0x00007ffff7cc9361 in grpc_init () from /usr/local/lib/libgrpc.so.9
#4  0x0000555555564e36 in grpc::GrpcLibraryCodegen::GrpcLibraryCodegen (this=0x55555559bd30, call_grpc_init=true) at /usr/local/include/grpcpp/impl/codegen/grpc_library.h:45
#5  0x00007ffff7edf49e in grpc_impl::ServerBuilder::BuildAndStart() () from /usr/local/lib/libgrpc++.so.1
#6  0x0000555555575c29 in RunServer () at greeter_server.cc:61
#7  0x0000555555575d7d in main (argc=1, argv=0x7fffffffdb78) at greeter_server.cc:71

1 个答案:

答案 0 :(得分:1)

确保不要将库grpc_unsecure与其他grpc库链接在一起。.

https://github.com/grpc/grpc/issues/20757#issuecomment-545773014