[Lldb-commits] [lldb] f2f9459 - [lldb] Protect frame provider construction from re-entrant frame access
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 25 23:21:04 PDT 2026
Author: Med Ismail Bennani
Date: 2026-03-25T23:20:33-07:00
New Revision: f2f94597671f897dc939facd756f0be58fdf017e
URL: https://github.com/llvm/llvm-project/commit/f2f94597671f897dc939facd756f0be58fdf017e
DIFF: https://github.com/llvm/llvm-project/commit/f2f94597671f897dc939facd756f0be58fdf017e.diff
LOG: [lldb] Protect frame provider construction from re-entrant frame access
When a scripted frame provider calls HandleCommand or other
frame-accessing APIs during __init__, GetStackFrameList() re-enters
without the re-entrancy guard, causing infinite recursion. On Windows
(1MB default stack), this results in a stack overflow (0xC00000FD)
before Python's recursion limit can intervene.
The existing PushProviderFrameList/PopProviderFrameList guard only
protected GetFrameAtIndex calls in FetchFramesUpTo. This wraps the
CreateInstance call in LoadScriptedFrameProvider with the same guard
so that provider construction is also protected.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
Added:
Modified:
lldb/source/Target/Thread.cpp
Removed:
################################################################################
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 6ecca96ebb02e..9e977481546b9 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1632,8 +1632,15 @@ llvm::Error Thread::LoadScriptedFrameProvider(
last_id);
}
+ // Protect provider construction (__init__) from re-entrancy. If the
+ // provider calls back into the frame machinery (e.g. HandleCommand("bt"))
+ // during __init__, GetStackFrameList() will find this thread in the
+ // active-provider map and return input_frames instead of trying to
+ // build a new synthetic list — preventing infinite recursion.
+ PushProviderFrameList(input_frames);
auto provider_or_err =
SyntheticFrameProvider::CreateInstance(input_frames, descriptor);
+ PopProviderFrameList();
if (!provider_or_err)
return provider_or_err.takeError();
More information about the lldb-commits
mailing list