Skip to content
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

add_method_tracer modifies object arguments #424

Closed
dipth opened this issue Sep 8, 2020 · 2 comments · Fixed by #499
Closed

add_method_tracer modifies object arguments #424

dipth opened this issue Sep 8, 2020 · 2 comments · Fixed by #499
Labels
bug community To tag external issues and PRs submitted by the community

Comments

@dipth
Copy link

dipth commented Sep 8, 2020

add_method_tracer causes object arguments to be cloned.

Description

When tracing a method that takes an object argument that is supposed to be mutated during the execution of that method, the tracing causes the passed argument to be a clone of the object, meaning that any mutations are lost to outside references to the same object.

Expected Behavior

No cloning of arguments should happen and the passed object should be included in the call to the method as is.

Steps to Reproduce

class Demonstration
  include ::NewRelic::Agent::MethodTracer

  def call
    (1..10).each_with_object({}) do |i, hash|
      process(i, hash)
    end
  end

  def process(i, hash)
    hash[i] = i * 2
  end

  add_method_tracer :process, 'Demonstration/process'
end

Demonstration.new.call
#=> {}

Expected result:

Demonstration.new.call
=> {1=>2, 2=>4, 3=>6, 4=>8, 5=>10, 6=>12, 7=>14, 8=>16, 9=>18, 10=>20}

Your Environment

ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]

Additional context

It seems like this is not an issue in Ruby 2.6

@tannalynn
Copy link
Contributor

Hello @dipth. We will take a closer look at this.
Thank you for bringing this to our attention.

@tannalynn tannalynn added the bug label Sep 8, 2020
@angelatan2 angelatan2 added this to Triage in Ruby Engineering Board via automation Sep 10, 2020
@angelatan2 angelatan2 added this to the Q3 Ruby Bug Smash milestone Sep 18, 2020
@mwlang
Copy link
Contributor

mwlang commented Oct 5, 2020

This should be solved by this PR: #422

@angelatan2 angelatan2 moved this from Triage to Backlog in Ruby Engineering Board Oct 21, 2020
@mwlang mwlang moved this from Backlog to In progress in Ruby Engineering Board Nov 2, 2020
@github-actions github-actions bot added the stale label Nov 5, 2020
@newrelic newrelic deleted a comment from github-actions bot Nov 5, 2020
@mwlang mwlang removed the stale label Nov 5, 2020
Ruby Engineering Board automation moved this from In progress to Done/Pending Release Nov 13, 2020
@angelatan2 angelatan2 added the community To tag external issues and PRs submitted by the community label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug community To tag external issues and PRs submitted by the community
Projects
Archived in project
Ruby Engineering Board
  
Code Complete/Done
Development

Successfully merging a pull request may close this issue.

4 participants