Skip to content

mgr/ActivePyModules: fix dangling string_view in get_perf_schema_python - #66824

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
NitzanMordhai:wip-nitzan-activepymodules-perf-schema-labels-pyformatter
Mar 30, 2026
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
NitzanMordhai:wip-nitzan-activepymodules-perf-schema-labels-pyformatter

Conversation

@NitzanMordhai

@NitzanMordhai NitzanMordhai commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

prev_key_name and key_name variables were declared as std::string_view but prev_key_name was assigned from key_name, which points to key_name_without_counter's buffer. This buffer is overwritten each iteration, causing prev_key_name and key_name to become a dangling pointers.

This results in corrupted comparisons and can cause assertion failures like ("cursor != root" in PyFormatter::close_section) or segmentation faults when the corrupted string is passed back to telemetry.

Https://github.com/ceph/ceph/pull/61997 added that code

Fixes: https://tracker.ceph.com/issues/74286

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@NitzanMordhai
NitzanMordhai requested a review from a team as a code owner January 7, 2026 14:46
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-activepymodules-perf-schema-labels-pyformatter branch from a763d4c to e007a52 Compare January 7, 2026 14:47
Comment thread src/mgr/ActivePyModules.cc Outdated
if (key_labels.empty()) {
size_t pos = counter_name_with_labels.rfind('.');
key_name_without_counter = counter_name_with_labels.substr(0, pos);
key_name = key_name_without_counter; // key_name, osd
key_name = std::string(counter_name_with_labels.substr(0, pos)); // key_name, osd

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.

counter_name_with_labels is a string, if I am not mistaken. Thus xx.substr() is a string, too.
No need for the std::string() around it.

And a minor note: I do not object to specifying the full std::string path, but in this case: ActiveModule.cc has a 'using std::string' line above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm keeping the full std::string path. ActivePyModules use it all over the functions

prev_key_name and key_name variables were declared as std::string_view but
prev_key_name was assigned from key_name, which points to
key_name_without_counter's buffer. This buffer is overwritten each iteration,
causing prev_key_name and key_name to become a dangling pointers.

This results in corrupted comparisons and can cause assertion failures like
("cursor != root" in PyFormatter::close_section) or segmentation faults
when the corrupted string is passed back to telemetry.

Fixes: https://tracker.ceph.com/issues/74286
Signed-off-by: Nitzan Mordechai <[email protected]>
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-activepymodules-perf-schema-labels-pyformatter branch from e007a52 to 26d10b3 Compare January 8, 2026 06:32
@NitzanMordhai
NitzanMordhai requested a review from ronen-fr January 8, 2026 06:34
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@ronen-fr ronen-fr 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.

LGTM

@Naveenaidu

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants