You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Review-driven fixes to the ContractExecutor libfunc-profiling path:
- ArcProgram alias (orizi review on src/executor.rs): replace the bare
`pub use ...::Program` re-export with `pub type ArcProgram = Arc<Program>`,
since profiling/sierra-emu consumers only ever hold the program as a shared
handle. Gated on `any(sierra-emu, with-libfunc-profiling)` so EmuContractInfo
consumers can name the field type too, and adopted for EmuContractInfo.program,
AotWithProgram.program, and the run_with_profile callback.
- Self-deadlock: run_with_libfunc_profile held the non-reentrant process-wide
PROFILE_LOCK across self.run, which re-enters this function on the same thread
whenever a profiled contract calls another contract -- a guaranteed hang. Take
the lock only at the outermost profiled frame per thread (tracked via a
thread-local PROFILE_DEPTH); nested frames inherit the outer frame's lock, and
the existing per-call old_trace_id save/restore keeps the global trace-id symbol
correct across nesting. Cross-thread isolation is preserved (the outermost frame
holds the lock for the whole run tree). A ProfileDepthGuard decrements the depth
on every exit path including unwind.
- FFI panic-safety: ProfilerImpl::push_stmt is a `pub extern "C" fn` invoked
directly from compiled Cairo code; its `.lock().unwrap()` would unwind across the
C ABI on a poisoned mutex. Recover from poison instead, matching the lock handling
in run_with_libfunc_profile.
- Instrumented compiler binary: add a `with-libfunc-profiling` feature to
starknet-native-compile forwarding to `cairo-native/with-libfunc-profiling`, so an
instrumented binary (whose emitted .so carries the profiler symbol that
run_with_libfunc_profile looks up) can be built. A binary built without it produces
.so files with no profiler symbol, making every profiled call fail.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments