Skip to content

Commit 3e12ac0

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
Add null check for getModuleState() in cinderx_func_watcher destroy handler
Summary: During interpreter shutdown, PyFunction_EVENT_DESTROY can fire after removeModuleState() has set the global state to nullptr. Add a nullptr check before dereferencing, consistent with the pattern already used in cinderx_dict_watcher. Reviewed By: DinoV Differential Revision: D96862271 fbshipit-source-id: e4329c48d82238081388e17e0db795b470d5ac56
1 parent bbff470 commit 3e12ac0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cinderx/_cinderx-lib.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,11 @@ int cinderx_func_watcher(
856856
#endif
857857
case PyFunction_EVENT_DESTROY:
858858
if (jit::perf::isPreforkCompilationEnabled()) {
859-
auto& perf_trampoline_worklist =
860-
cinderx::getModuleState()->perf_trampoline_worklist;
861-
perf_trampoline_worklist.erase(func);
859+
auto state = cinderx::getModuleState();
860+
if (state != nullptr) {
861+
auto& perf_trampoline_worklist = state->perf_trampoline_worklist;
862+
perf_trampoline_worklist.erase(func);
863+
}
862864
}
863865
jit::funcDestroyed(func);
864866
break;

0 commit comments

Comments
 (0)