THREAD_ALLOC dereferences a null thread while THREAD_FREE falls back to the global allocator

Ouverte Adaptée aux débutants
#14,217 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
cpp
Domaine
backend

Piste de recherche

Commencez par les macros THREAD_ALLOC, SAFE_THREAD_ALLOC et THREAD_FREE dans include/iocore/eventsystem/ProxyAllocator.h (lignes 87–110). Comparez leur comportement avec un thread nul et vérifiez les appelants indiqués dans IOBuffer.cc, InkAPI.cc et cripts/unit_tests/main.cc. Le travail est terminé lorsque l’allocation depuis un thread non enregistré ne déréférence plus de pointeur nul et qu’un test approprié couvre le fallback ou le diagnostic prévu.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Bug Event System Threads

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

Langage dominant
C++
Étoiles
2k
Forks
903
Merge moyen
4 j 4 h
PR mergées (30 j)
135

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/trafficserver

Toutes les issues de apache/trafficserver

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.