File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ class PyGlobals {
134134
135135 bool isUserTracebackFilename (llvm::StringRef file);
136136
137+ static constexpr size_t kMaxFrames = 512 ;
138+
137139 private:
138140 nanobind::ft_mutex mutex;
139141 bool locTracebackEnabled_ = false ;
Original file line number Diff line number Diff line change @@ -2786,18 +2786,16 @@ class PyOpAttributeMap {
27862786 PyOperationRef operation;
27872787};
27882788
2789- constexpr size_t kMaxFrames = 512 ;
2790-
27912789MlirLocation tracebackToLocation (MlirContext ctx) {
27922790 size_t framesLimit =
27932791 PyGlobals::get ().getTracebackLoc ().locTracebackFramesLimit ();
27942792 // Use a thread_local here to avoid requiring a large amount of space.
2795- thread_local std::array<MlirLocation, kMaxFrames > frames;
2793+ thread_local std::array<MlirLocation, PyGlobals::TracebackLoc::kMaxFrames >
2794+ frames;
27962795 size_t count = 0 ;
27972796
27982797 nb::gil_scoped_acquire acquire;
27992798 PyThreadState *tstate = PyThreadState_GET ();
2800-
28012799 PyFrameObject *next;
28022800 PyFrameObject *pyFrame = PyThreadState_GetFrame (tstate);
28032801 for (; pyFrame != nullptr && count < framesLimit;
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ size_t PyGlobals::TracebackLoc::locTracebackFramesLimit() {
215215
216216void PyGlobals::TracebackLoc::setLocTracebackFramesLimit (size_t value) {
217217 nanobind::ft_lock_guard lock (mutex);
218- locTracebackFramesLimit_ = value;
218+ locTracebackFramesLimit_ = std::min ( value, kMaxFrames ) ;
219219}
220220
221221void PyGlobals::TracebackLoc::registerTracebackFileInclusion (
You can’t perform that action at this time.
0 commit comments