Skip to content

Commit a1d4d35

Browse files
committed
[executorch][devtools] Reset profiler state in ETDump tests
Pull Request resolved: pytorch#21410 Reinitialize the global profiler state before each `ETDumpGenTest` while initializing the runtime once per suite. This prevents profile blocks from leaking across XCTest cases, exhausting the fixed block pool, and causing assertion failures or process crashes. This fixes nine TestInfra signals. This commit was authored with Claude. ghstack-source-id: 407467887 @exported-using-ghexport Differential Revision: [D113810097](https://our.internmc.facebook.com/intern/diff/D113810097/)
1 parent e43f7e5 commit a1d4d35

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎runtime/platform/profiler.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ void profiling_create_block(const char* name) {
182182
}
183183

184184
void profiler_init(void) {
185+
prof_header = (prof_header_t*)((uintptr_t)prof_buf + prof_header_offset);
186+
prof_arr = (prof_event_t*)((uintptr_t)prof_buf + prof_events_offset);
187+
mem_allocator_arr =
188+
(prof_allocator_t*)((uintptr_t)prof_buf + prof_mem_alloc_info_offset);
189+
mem_prof_arr =
190+
(mem_prof_event_t*)((uintptr_t)prof_buf + prof_mem_alloc_events_offset);
191+
num_blocks = 0;
192+
prof_stats_dumped = false;
193+
profile_state_tls = {-1, 0u};
185194
profiling_create_block("default");
186195
}
187196

0 commit comments

Comments
 (0)