apache / apache/pulsar-client-cpp

[Bug] Pulsar client can't have static storage duration

オープン
#56 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
71
フォーク
90
平均マージ
2時間 33分
マージ済み PR(30日)
3

説明

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.

### Version

- pulsar client 2.9.0
- ubuntu linux

### Minimal reproduce step

int main(int argc, char** argv)
{
static ::pulsar::Client client{"pulsar://0.0.0.0:6650"};
// don't call client.close();
return 0;
}

### What did you expect to see?

The program should terminate gracefully, instead it seg faults. If I call client.close(), there is no issue.

### What did you see instead?

The program seg faults with the following trace:

In gdb:
```
Program received signal SIGSEGV, Segmentation fault.
0x000000000000001e in ?? ()
(gdb) bt
#0 0x000000000000001e in ?? ()
#1 0x00007fb5adff4bef in ?? () from /lib/libpulsar.so.2.9.2.13
#2 0x00007fb5adff76e4 in ?? () from /lib/libpulsar.so.2.9.2.13
#3 0x00000000002e0873 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0xb1e400) at /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/shared_ptr_base.h:155
#4 0x00000000002e082a in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x51b370 ) at /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/shared_ptr_base.h:730
#5 0x00000000002e0f29 in std::__shared_ptr::~__shared_ptr (this=0x51b368 ) at /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/shared_ptr_base.h:1169
#6 0x00000000002e0f05 in std::shared_ptr::~shared_ptr (this=0x51b368 ) at /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/shared_ptr.h:103
#7 0x00000000002dfde5 in pulsar::Client::~Client (this=0x51b368 ) at /usr/include/pulsar/Client.h:46
#8 0x00007fb5ad93f8a7 in __run_exit_handlers (status=0, listp=0x7fb5adae5718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#9 0x00007fb5ad93fa60 in __GI_exit (status=) at exit.c:139
#10 0x00007fb5ad91d08a in __libc_start_main (main=0x2df330 , argc=3, argv=0x7ffd9fae0c18, init=, fini=, rtld_fini=, stack_end=0x7ffd9fae0c08) at ../csu/libc-start.c:342
#11 0x00000000002df26e in _start ()
```

### Anything else?

_No response_

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Ubuntu 上で最小限の静的な pulsar::Client の再現から始め、/usr/include/pulsar/Client.h にある pulsar::Client::~Client を調べます。次に、提供された gdb バックトレースを使って、シャットダウンと shared-pointer の破棄を追跡します。client.close(); なしで静的破棄が実行されると失敗することを確認します。明示的な close を必要とせずにプログラムが正常終了すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
distributed-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。