Boost >= 1.87 throws bad_alloc when allocating memory for a 64-byte aligned data structure using managed_shared_memory, even though there is sufficient free memory
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- cpp
調査の方向性
提供された managed_shared_memory の例を MyClass<32768> で再現し、include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp の allocate_aligned を調査して、言及されている Boost バージョン間での動作を比較します。real_size が get_free_memory に対してどのように計算されるかを追跡します。回帰が説明され、アラインされた割り当ての動作が適切な回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi there, I haven't tested this with Boost 1.86, jumped straight from 1.85 to 1.87. The code snippet below works well in Boost 1.85, but when using 1.87 or 1.88, I noticed it fails and throw bad_alloc. Some changes related to memory_algorithm seem to break it. While debugging, I found that the real_size calculated in allocate_aligned is larger than the currently available free memory. I'm also wondering if I'm using it incorrectly. Please advise — thanks!
#include <iostream>
#include "boost/interprocess/interprocess_fwd.hpp"
#include "boost/interprocess/managed_shared_memory.hpp"
#include "boost/interprocess/shared_memory_object.hpp"
template <size_t N)>
class MyClass {
public:
static_assert((N & (N - 1)) == 0, "size must be power of 2");
private:
alignas(64) std::array<uint8_t, N> data_;
};
namespace bip = boost::interprocess;
int main() {
constexpr auto kName = "TestShm";
bip::shared_memory_object::remove(kName);
try {
auto shm = bip::managed_shared_memory(bip::open_or_create, kName,
65536);
auto free_mem = shm.get_free_memory();
std::cout << "Free mem: " << free_mem << std::endl;
using Data = MyClass<32768>;
[[maybe_unused]] auto data = shm.find_or_construct<Data>("Data")();
}
catch (const std::exception& e) {
std::cout << "Fail, " << e.what() << std::endl;
bip::shared_memory_object::remove(kName);
return 1;
}
bip::shared_memory_object::remove(kName);
return 0;
}
- 主要言語
- HTML
- スター
- 8.6k
- フォーク
- 2k
- 平均マージ
- 9時間 35分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/boost のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
似ている issue
-
agent:WSL code-review linux pri:medium refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
sys_full_path on Windows copies only half of each path part's case on disk対応中かも @dimensionscape が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
HaxeFoundation/hashlink#1026 ·
メンテナーはふだん 1 日以内に返信
-
stdlib topic-subprocess type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: linux bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 5 日以内に返信