MallocAllocator does not check for allocation failure

オープン 初心者向け
#14,218 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@umrndem がすでに取り組んでいます。

2026年12月5日 から。

  • #14287 @umrndem による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
backend, devtools

調査の方向性

include/tscore/Allocator.hを読み、特に137~148行目のMallocAllocator::alloc_void()と343~345行目のClassAllocator::alloc()を確認してください。割り当て失敗時の処理を、245行目付近にあるsrc/tscore/ink_queue.ccのats_mallocおよびats_memalignの経路と比較してください。割り当てに失敗したときに、nullポインターのまま処理を続けず、メモリ不足を明確に示すエラーが発生すれば完了です。issueではテストについて言及されていません。

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

説明

Bug Core Good First Issue

With ENABLE_MALLOC_ALLOCATOR, Allocator is MallocAllocator (Allocator.h#L315-L325). MallocAllocator::alloc_void() returns the result of malloc or aligned_alloc without checking it, and calls madvise on it first (Allocator.h#L137-L148). ClassAllocator::alloc() then placement-news the object at the returned pointer (Allocator.h#L343-L345).

On allocation failure, the object is therefore constructed at nullptr, which is undefined behavior and normally a crash at some later, unrelated-looking point. The default freelist allocator gets its memory through ats_malloc/ats_memalign (ink_queue.cc#L245), which abort with a clear out-of-memory message. The malloc build should behave the same way.

Suggested fix: allocate through ats_malloc/ats_memalign in MallocAllocator::alloc_void(), or check the result and abort with an out-of-memory error.


generated with Claude Opus 5.5 by Josiah VanderZee

主要言語
C++
スター
2k
フォーク
903
平均マージ
4日 4時間
マージ済み PR(30日)
135

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/trafficserver のほかの issue

apache/trafficserver の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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