Skip to content

make phase trace be a no-op if the feature is not enabled - #2286

Draft
sdwoodbury wants to merge 1 commit into
mainfrom
sw/fix_phase_trace
Draft

make phase trace be a no-op if the feature is not enabled#2286
sdwoodbury wants to merge 1 commit into
mainfrom
sw/fix_phase_trace

Conversation

@sdwoodbury

Copy link
Copy Markdown
Collaborator

Prevent panic when a binary is compiled with the phase_trace feature enabled but phase_tracer::init() was not called.

This was observed when running construct-graph-ptxt. Currently only the Hawk server (hawk_main.rs:1728) calls phase_tracer::init().

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CPU Hawk phase tracing utility (iris-mpc-cpu) so that phase tracing calls become a safe no-op when the global tracer was not initialized, preventing runtime panics in binaries compiled with feature = "phase_trace" that don’t call phase_tracer::init().

Changes:

  • Make PhaseGuard optionally hold a tracer sender (Option<&'static Sender<_>>) and become a no-op when uninitialized.
  • Update phase_begin() to return a no-op PhaseGuard when TRACER is unset, instead of panicking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +164
// Degrade to a no-op guard if the tracer was never initialized (e.g. when a
// tool other than the Hawk server is compiled with the `phase_trace` feature).
let Some(tracer) = TRACER.get() else {
return PhaseGuard {
name,
tid: String::new(),
tx: None,
pid: 0,
start_time: Instant::now(),
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants