MallocAllocator does not check for allocation failure
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read include/tscore/Allocator.h, especially MallocAllocator::alloc_void() at lines 137–148 and ClassAllocator::alloc() at lines 343–345. Compare the allocation failure handling with the ats_malloc and ats_memalign path in src/tscore/ink_queue.cc around line 245. Done means allocation failure produces a clear out-of-memory failure instead of continuing with a null pointer; the issue does not name a test.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C++
- Stars
- 2k
- Forks
- 903
- Avg merge
- 4d 4h
- Merged PRs (30d)
- 135
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/trafficserver
-
UnixNetVConnection::do_io_write with a null reader leaves the previous reader in the write VIOPossibly taken @NginxL claimed this today. OpenBug Good First Issue IOBuffer Network
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/trafficserver#14220 ·
Maintainers usually reply within 2 days
-
Bug Event System Threads
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/trafficserver#14217 ·
Maintainers usually reply within 2 days
-
TSContScheduleEveryOnPool and TSContScheduleEveryOnThread accept a zero or negative periodPossibly taken @rajeetvk claimed this 1 day ago. OpenBug Event System Good First Issue TS API
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/trafficserver#14214 · 1 comment ·
Maintainers usually reply within 2 days
-
HostDBContinuation::init memsets a polymorphic ActionPossibly taken @ANMOLSCRIPT claimed this today. OpenBug Good First Issue HostDB
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/trafficserver#14204 · 1 comment ·
Maintainers usually reply within 2 days
-
Bug Core Event System Logging Startup
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/trafficserver#14201 ·
Maintainers usually reply within 2 days
All issues in apache/trafficserver
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 2 days
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug compatibility difficulty:easy prio:normal
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NatronGitHub/openfx-misc#524 ·
Maintainers usually reply within 1 day
-
documentation enhancement help wanted P0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Awesome-Embedded-Learning-Studio/Tutorial_AwesomeModernCPP#359 ·
Maintainers usually reply within 1 day
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openscad/openscad#7360 · 2 comments ·
Maintainers usually reply within 1 day