【问题标题】:Are there any limitations to starting multiple grpc::ServerBuilders in an application?在应用程序中启动多个 grpc::ServerBuilders 是否有任何限制?
【发布时间】:2017-10-19 23:03:06
【问题描述】:

我在 Ubuntu 14.04 上运行的 C++ 应用程序出现问题。我正在使用 grpc 与 go webserver 应用程序通信,该应用程序正在为网页提供 c++ 应用程序的状态/配置。

我一直在使用 1 年前的 grpc 0.14 版本,所以在发布之前,我升级了所有东西(grpc 1.3.1,去版本 1.8.1)。

似乎我的 c++ 应用程序在 1.3.1(以及 1.0.0、1.2.5、1.2.0 等)grpc 版本中经常崩溃。

我收到带有双重免费警告的 sigabort。应用程序会运行一段时间,但在 Web 应用程序向 c++ 应用程序请求数据的一段时间后,它会崩溃:gdb 输出:

[New LWP 9908]
[New LWP 9881]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./bhio'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  _int_malloc (av=0x7fb3ac000020, bytes=16) at malloc.c:3351
3351    malloc.c: No such file or directory.
(gdb) where
#0  _int_malloc (av=0x7fb3ac000020, bytes=16) at malloc.c:3351
#1  0x00007fb4205db6c0 in __GI___libc_malloc (bytes=16) at malloc.c:2891
#2  0x000000000076bb2f in gpr_malloc ()
#3  0x000000000077678d in grpc_error_create ()
#4  0x000000000078ba94 in ?? ()
#5  0x000000000078dbee in grpc_chttp2_fail_pending_writes ()
#6  0x000000000078e19f in grpc_chttp2_mark_stream_closed ()
#7  0x000000000078e2eb in grpc_chttp2_cancel_stream ()
#8  0x000000000078ef1c in ?? ()
#9  0x000000000077597e in grpc_combiner_continue_exec_ctx ()
#10 0x0000000000777678 in grpc_exec_ctx_flush ()
#11 0x000000000078095f in grpc_call_cancel_with_status ()
#12 0x0000000000780be1 in grpc_call_destroy ()
#13 0x0000000000769bd7 in grpc::ServerContext::~ServerContext() ()
#14 0x0000000000768c7c in grpc::Server::SyncRequest::CallData::~CallData() ()
#15 0x00000000007691e3 in 
grpc::Server::SyncRequestThreadManager::DoWork(void*, bool) ()
#16 0x000000000076aff1 in grpc::ThreadManager::MainWorkLoop() ()
#17 0x000000000076b04c in grpc::ThreadManager::WorkerThread::Run() ()
#18 0x00007fb420eebbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#19 0x00007fb421146184 in start_thread (arg=0x7fb3ca686700)
at pthread_create.c:312
#20 0x00007fb42065337d in clone ()
---Type <return> to continue, or q <return> to quit---
  at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb)
(gdb) quit

或这里:

[Thread 0x7fff7d7fa700 (LWP 3521) exited]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff7e7fc700 (LWP 3524)]
__GI___libc_free (mem=0xb5) at malloc.c:2929
2929    malloc.c: No such file or directory.
(gdb)
(gdb) where
#0  __GI___libc_free (mem=0xb5) at malloc.c:2929
#1  0x000000000077b7b5 in grpc_byte_buffer_destroy ()
#2  0x0000000000773ac3 in grpc::Server::SyncRequest::CallData::~CallData() ()
#3  0x000000000077405a in grpc::Server::SyncRequestThreadManager::DoWork(void*, bool) ()
#4  0x0000000000776111 in grpc::ThreadManager::MainWorkLoop() ()
#5  0x000000000077616c in grpc::ThreadManager::WorkerThread::Run() ()
#6  0x00007ffff6c9fbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff6efa184 in start_thread (arg=0x7fff7e7fc700)
at pthread_create.c:312
#8  0x00007ffff640737d in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

所以如果可以启动多个 serverbuilder s ,上述错误还能指出我在使用 grpc 库时可能做错了什么。我将这段代码交给其他编写它的人,所以我对grpc的使用知识欠缺……我觉得grpc没那么不稳定,所以一定是我用错了。

任何想法都会有所帮助..

任何更好地调试它的建议都会有所帮助。

对于 grpc 构建,我只是在做以下事情:

$ git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc

$ cd grpc

$ git submodule update --init

$ 制作

$ [sudo] 安装

是否有不同的编译选项可以提供更多信息?

提前感谢您的帮助/建议。

鲍勃

【问题讨论】:

  • 事实证明,注册的服务函数中的一个小内存泄漏(缺少套接字文件描述符的关闭)导致了这个问题。我想我无法关闭此问题...请有人为我完成。

标签: grpc


【解决方案1】:

事实证明,注册的服务函数中的一个小内存泄漏(丢失了套接字文件描述符的关闭)导致了这个问题。

【讨论】:

    猜你喜欢
    • 2012-07-03
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多