Skip to content

Replace panics in dynamic location handling with safe fallback#287

Closed
utpilla wants to merge 1 commit into
microsoft:mainfrom
utpilla:utpilla/Replace-todo-macro-with-empty
Closed

Replace panics in dynamic location handling with safe fallback#287
utpilla wants to merge 1 commit into
microsoft:mainfrom
utpilla:utpilla/Replace-todo-macro-with-empty

Conversation

@utpilla

@utpilla utpilla commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

EventFormat::get_data_with_offset_direct had two todo!() arms for LocationType::DynRelative and LocationType::DynAbsolute that panic the process if hit. This change replaces them with a single combined arm that returns EMPTY, matching the behavior of every other failure path in the same function.

Motivation

These variants are produced by Linux tracefs (parsing __rel_loc / __dyn_loc markers) and by the cross-platform ScriptEvent::append_field helper. Whether any current caller actually feeds such a field into get_data_with_offset_direct is not obvious from a single review pass. For example: open-telemetry/otel-arrow#3187 (comment)

A todo!() here forces reviewer to either:

  • ask for defensive scaffolding (catch_unwind, etc.) around callers, or
  • chase the call graph to prove the branch is unreachable.

Both are wasted effort for a function whose every other failure mode already returns EMPTY. todo!() is a "not implemented yet" marker; using it in shipped code as a stand-in for "shouldn't happen" promotes a missing feature to a potential process-killing panic and adds review friction.


LocationType::DynAbsolute => {
todo!("Need to support absolute location");
LocationType::DynRelative | LocationType::DynAbsolute => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to handle these, as the data closure generation calls into get_field_data_closure() which eventually leads here. get_field_data_closure() should be updated to handle these cases as well as this function.

The todo() here is to track that work is yet to be done. We should either do the work here or keep the todo() since it's tracking that left over work.

@utpilla

utpilla commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #293

@utpilla utpilla closed this Jun 16, 2026
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