Fix heap-use-after-free in VlRNG::VlRNG() due to dangling thread-local t_currentp

When a function (e.g. eval_static) creates a VlProcess via make_shared
and sets VlProcess::currentp(vlProcess.get()), the thread-local
t_currentp pointer is left dangling after the shared_ptr destroys the
VlProcess object at function exit. A subsequent function (e.g.
eval_initial) that constructs a new VlProcess triggers VlRNG::VlRNG(),
which calls VlProcess::currentRng() and reads the freed t_currentp,
causing a heap-use-after-free.

Fix by clearing t_currentp in ~VlProcess() when it points to the
dying object, redirecting to the parent process if one exists.
This commit is contained in:
Dragon-Git 2026-07-03 09:18:05 +08:00
parent 0e371d6e5c
commit 54d715fc44
2 changed files with 3 additions and 1 deletions

View File

@ -61,6 +61,7 @@ David Turner
Dercury
Diego Roux
Dominick Grochowina
Dragon-Git
Don Williamson
Drew Ranck
Drew Taussig
@ -334,4 +335,4 @@ Yogish Sekhar
Zubin Jain
Muzaffer Kal
Yilin Li
Shashvat Prabhu
Shashvat Prabhu

View File

@ -337,6 +337,7 @@ public:
~VlProcess() {
if (m_parentp) m_parentp->detach(this);
if (t_currentp == this) t_currentp = m_parentp;
}
void attach(VlProcess* childp) { m_children.insert(childp); }