~EThread does not close its eventfd or pipe, leaking descriptors per TSThreadCreate/TSThreadDestroy

Open Beginner friendly
#14,199 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, linux

Research direction

Read the eventfd/pipe setup in src/iocore/eventsystem/UnixEThread.cc around lines 100–141 and the dedicated thread lifecycle in src/api/InkIOCoreAPI.cc around lines 92 and 215. Check how the descriptors are initialized and which values indicate they were opened, then verify destruction closes the applicable descriptors. Done when repeated plugin thread creation and destruction no longer leaves those descriptors open.

Written by the indexing model from the issue text.

Description

Bug Core Event System Leak Threads TS API

EThread(ThreadType, int) opens an eventfd (or, without eventfd, a pipe) for waking the thread (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/iocore/eventsystem/UnixEThread.cc#L100-L122). ~EThread releases the thread mutex but never closes evfd or evpipe (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/iocore/eventsystem/UnixEThread.cc#L132-L141).

Most event threads live for the whole process, but INKThreadInternal, which backs the plugin thread API, is constructed with EThread(DEDICATED, -1) (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/api/InkIOCoreAPI.cc#L92), so every TSThreadCreate or TSThreadInit opens a descriptor (two for the pipe), and TSThreadDestroy deletes the object (https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/src/api/InkIOCoreAPI.cc#L215) without closing them. A plugin that creates and destroys threads repeatedly (for example plugins/experimental/magick, https://github.com/apache/trafficserver/blob/eeeada36e1dff81822977bc36016d4264d64cdb8/plugins/experimental/magick/magick.cc#L111) leaks one descriptor per thread until it hits the fd limit.

Suggested fix: close evfd / evpipe[0..1] in ~EThread when they were opened. A dedicated thread may not need a wakeup descriptor at all.


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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/trafficserver

All issues in apache/trafficserver

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.