THREAD_ALLOC dereferences a null thread while THREAD_FREE falls back to the global allocator
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with the THREAD_ALLOC, SAFE_THREAD_ALLOC, and THREAD_FREE macros in include/iocore/eventsystem/ProxyAllocator.h (lines 87–110). Compare their null-thread behavior and check the callers named in IOBuffer.cc, InkAPI.cc, and cripts/unit_tests/main.cc. Done means allocation from an unregistered thread no longer dereferences a null pointer, with the intended fallback or diagnostic covered by an appropriate test.
Written by the indexing model from the issue text.
Description
THREAD_ALLOC and THREAD_ALLOC_INIT expand to thread_alloc(::_a, _t->_a, ...) and dereference the thread pointer unconditionally (ProxyAllocator.h#L87-L88). The matching THREAD_FREE checks for a null thread and frees to the global allocator instead (ProxyAllocator.h#L109-L110), and SAFE_THREAD_ALLOC does the same for allocation (ProxyAllocator.h#L89).
Most callers pass this_thread() or this_ethread(), which is null on any OS thread not registered with the event system. Examples include new_MIOBuffer / new_IOBufferBlock (IOBuffer.cc#L171, IOBuffer.cc#L723), TSContCreate() (InkAPI.cc#L3844) and TSVConnCreate() (InkAPI.cc#L6426). Allocating from an unregistered thread crashes, but freeing the same object there works. Setting cmd_disable_pfreelist doesn't help either, because the macro still evaluates _t->_a. The cripts unit test has to register a fake EThread on main for this reason (cripts/unit_tests/main.cc#L41-L45).
Suggested fix: give THREAD_ALLOC the same null fallback as THREAD_FREE (i.e. make it SAFE_THREAD_ALLOC), or turn the null case into an ink_release_assert with a message, so a plugin calling these APIs from its own thread gets a diagnosable error rather than a segfault.
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
-
MallocAllocator does not check for allocation failurePossibly taken @umrndem claimed this today. OpenBug Core Good First Issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/trafficserver#14218 · 2 comments ·
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