make phase trace be a no-op if the feature is not enabled - #2286
Draft
sdwoodbury wants to merge 1 commit into
Draft
make phase trace be a no-op if the feature is not enabled#2286sdwoodbury wants to merge 1 commit into
sdwoodbury wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
PhaseGuardoptionally hold a tracer sender (Option<&'static Sender<_>>) and become a no-op when uninitialized. - Update
phase_begin()to return a no-opPhaseGuardwhenTRACERis 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(), | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevent panic when a binary is compiled with the
phase_tracefeature enabled butphase_tracer::init()was not called.This was observed when running
construct-graph-ptxt. Currently only the Hawk server (hawk_main.rs:1728) callsphase_tracer::init().