Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Joe Rafaniello
    @jrafanie
    This explains why it's been getting worse... more extracted engines with more pathnames on the $PATH
    Jason Frey
    @Fryguy
    I really want to infect a Rails app and/or Ruby app, so we have a reproducer for those core teams
    Though core ManageIQ has had Pathname in autoload_paths for a LONG time
    Joe Rafaniello
    @jrafanie
    ok, I'll try infecting a vanilla rails app too
    Jason Frey
    @Fryguy
    care to share :jeans: ? this is exciting haha
    Joe Rafaniello
    @jrafanie
    doh
    I'll pretend I didn't already run it and know the results
    Jason Frey
    @Fryguy
    LOOL
    share anyways...I bet we can get a Ruby reproducer real soon
    (yes I said "anyways" just for you)
    Joe Rafaniello
    @jrafanie
    Nick LaMuro
    @NickLaMuro
    Script for replicating a ruby leak with pure ruby:
    require 'pathname'
    require 'fileutils'
    
    puts "Process: #{Process.pid}"
    
    paths = %w[
      dir_1
      dir_2
      dir_3
      dir_4
    ]
    
    
    paths.each do |path|
      Dir.mkdir path unless Dir.exists? path
      $LOAD_PATH.unshift(Pathname.new path)
    end
    
    FileUtils.touch "#{paths.last}/empty.rb"
    
    
    dot      = "."
    filename = "empty"
    
    1500.times { 1500.times { require filename }; print dot; GC.start; }
    Keenan Brock
    @kbrock
    nice
    Jason Frey
    @Fryguy
    this is easily the coolest thing we've found in a long time haha
    Nick LaMuro
    @NickLaMuro
    Jason Frey
    @Fryguy
    totally
    Keenan Brock
    @kbrock
    Nick - you forgot to freeze the strings. THAT is why you're leaking ;)
    :bomb: :runner:
    ok, real statement
    what versions of ruby show this as a bug?
    Jason Frey
    @Fryguy
    anything < 2.5
    Nick LaMuro
    @NickLaMuro
    ^ this
    Jason Frey
    @Fryguy
    not sure about 2.2 (didn't try it)
    Keenan Brock
    @kbrock
    is the fix as easy as it looks?
    Jason Frey
    @Fryguy
    Smaller script:
    require 'pathname'
    require 'fileutils'
    
    puts Process.pid
    
    Dir.mkdir("foo") unless Dir.exists?("foo")
    $LOAD_PATH.unshift(Pathname.new("foo"))
    
    FileUtils.touch("empty.rb")
    1500.times { 1500.times { require "empty" }; print "."; GC.start; }
    Nick LaMuro
    @NickLaMuro
    @kbrock basically a .to_s on all calls to autoload_paths
    which include some provider plugins
    Jason Frey
    @Fryguy
    yeah .to_s is a workaround for now
    basically to avoid putting Pathname objects into the LOAD_PATH
    Nick or LJ will open an issue on Ruby bug tracker
    Keenan Brock
    @kbrock
    how many PRs for our code base?
    Jason Frey
    @Fryguy
    3 or 4
    Keenan Brock
    @kbrock
    nice
    (per version I presume)
    Jason Frey
    @Fryguy
    yeah, we'll backport all the way
    Keenan Brock
    @kbrock
    are initializers run after all the engines and gems are included?
    Gregg Tanzillo
    @gtanzillo
    Amazing!!
    Keenan Brock
    @kbrock
    can we just fixup the paths in an initializer on our appliances?
    (short term fix)
    Jason Frey
    @Fryguy
    Rails itself modifies the LOAD_PATH with an initializer, so it's kind of complicated
    Jason Frey
    @Fryguy
    much easier to just tack on the .to_s in a dozen lines or so
    Keenan Brock
    @kbrock
    You get a score of <bad>
    We have a few ways to help increase your retirement score, like working for a few more years.
    --Fidelity
    Gee thanks. feels like the performance people saying: "Just buy more hardware"
    I was thinking you could write an initializer script that loops and to_s all the entries in the $LOAD_PATH
    Jason Frey
    @Fryguy
    $LOAD_PATH is not a "normal" Array, so not sure how you would do that
    like once it's in the LOAD_PATH, I don't think you can change it
    Keenan Brock
    @kbrock
    the uniq! seemed to suggest it is mutable
    Jason Frey
    @Fryguy
    but it probably has it's own implementation of uniq!
    Keenan Brock
    @kbrock
    you could unshift everything to_s and uniq! the thing?