boostorg / boostorg/program_options

Memory leaks when application is compiled with BOOST_DISABLE_THREADS

オープン
#70 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
136
フォーク
117
PR マージ指標
30日以内にマージされた PR はありません

説明

There's a memory leak if an application is compiled with BOOST_DISABLE_THREADS, is this expected behaviour?

test.cc:
``` c++
#include

int main(int argc, char *argv[]) {
boost::program_options::options_description opts{"Test"};
opts.add_options()
("help,h", boost::program_options::bool_switch(), "display this help and exit");

return 0;
}
```

Without `BOOST_DISABLE_THREADS` defined:
```
$ g++ -fsanitize=address test.cc -lboost_program_options -lboost_system -o test
$ ./test
$
```

With `BOOST_DISABLE_THREADS` defined:
```
$ g++ -fsanitize=address -DBOOST_DISABLE_THREADS test.cc -lboost_program_options -lboost_system -o test
=================================================================
==97000==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f675771777f in boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*) (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x3f77f)

Indirect leak of 176 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f6757732624 in boost::program_options::bool_switch(bool*) (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x5a624)

Indirect leak of 120 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f6757717761 in boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*) (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x3f761)
#2 0x7f6756d67b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Indirect leak of 27 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f67577155fc (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x3d5fc)

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f6757716593 in boost::program_options::option_description::option_description(char const*, boost::program_options::value_semantic const*, char const*) (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x3e593)

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7f6757a39458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7f67577326c5 in boost::program_options::bool_switch(bool*) (/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1+0x5a6c5)

SUMMARY: AddressSanitizer: 387 byte(s) leaked in 6 allocation(s).
```

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

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、提示された AddressSanitizer コマンドを使って、提供された test.cc を BOOST_DISABLE_THREADS ありとなしの両方でコンパイルし、リークレポートを比較します。program_options::options_description_easy_init と bool_switch を通じて報告された割り当てを追跡します。マクロがリークの原因になるかどうかを説明し、どちらのビルドにもリークを導入せずに修正できれば完了です。

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

評価

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

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

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