Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix rb_profile_frame_classpath to handle module singletons #3084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

casperisfine
Copy link
Contributor

@casperisfine casperisfine commented May 6, 2020

Ruby issue: https://bugs.ruby-lang.org/issues/16834

Right now SomeClass.method is properly named, but SomeModule.method
is displayed as #<Module:0x000055eb5d95adc8>.method which makes
profiling annoying.

This particularly impact StackProf.

cc @tenderlove @XrXr

@casperisfine
Copy link
Contributor Author

Also I can tell that it's a problem at least since Ruby 2.5, maybe older but there's not point backporting that far back.

@eregon
Copy link
Member

eregon commented May 6, 2020

Might relate to #2949 / https://bugs.ruby-lang.org/issues/15608.
Probably this output should be equivalent to the output of Method#inspect.

@casperisfine
Copy link
Contributor Author

Not sure. What you suggest sounds like a feature request (which I can agree of), whereas here I'm fixing a fairly obvious bug.

I think the PR is non-controversial, so it has a good chance to be accepted and backported quickly. Your suggestion need much more consensus.

@tenderlove
Copy link
Member

This looks good to me, but we should probably add tests for the behavior of anonymous modules and classes too.

Right now `SomeClass.method` is properly named, but `SomeModule.method`
is displayed as `#<Module:0x000055eb5d95adc8>.method` which makes
profiling annoying.
@casperisfine casperisfine force-pushed the handle-module-singletons-in-profile-frame-classpath branch from 4b96fdf to e99448b Compare May 7, 2020 08:19
@casperisfine
Copy link
Contributor Author

@tenderlove done. I added an anonymous module method in the stack.

Copy link
Contributor

@ko1 ko1 left a comment

Choose a reason for hiding this comment

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

seems nice.

@tenderlove tenderlove merged commit cbe4f75 into ruby:master May 7, 2020
@casperisfine
Copy link
Contributor Author

Thanks @tenderlove! Can one of you mark it as needing to be backported in https://bugs.ruby-lang.org/issues/16834 ? Would be nice to have this fix is the next minor versions.

@casperisfine casperisfine deleted the handle-module-singletons-in-profile-frame-classpath branch May 7, 2020 15:51
@tenderlove
Copy link
Member

@casperisfine I'll file a ticket to request a back port

@casperisfine
Copy link
Contributor Author

@tenderlove but it's already filed, isn't it? It simply need to have the backport field set (which only committers can set AFAIK).

@tenderlove
Copy link
Member

Ah yes, sorry! 🙇

ivoanjo added a commit to ivoanjo/backtracie that referenced this pull request Mar 25, 2021
…unctions to 2.6

ruby/ruby#3084 fixed the name returned for `qualified_method_name` for
module functions, but this fix was never added to 2.6.

By backporting the fix to 2.6, the test below now works for 2.6 as well:

```
  1) Backtracie.backtrace_locations when sampling a module_function on a module is expected to eq "ModuleWithFunction.test_function"
     Failure/Error: expect(backtracie_stack[2].qualified_method_name).to eq "ModuleWithFunction.test_function"

       expected: "ModuleWithFunction.test_function"
            got: "#<Module:0x000055fa25b00570>.test_function"

       (compared using ==)
     # ./spec/unit/backtracie_spec.rb:301:in `block (4 levels) in <top (required)>'
```
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.

5 participants