• Kerri Miller's avatar
    Explicitly call #to_a to avoid potential GC bug · 5cb6800c
    Kerri Miller authored
    We've seen a small number of seg faults that look to be coming from this
    method. One candidate for cause is a known issue in Ruby's GC with
    flat_map (https://bugs.ruby-lang.org/issues/18140) because the
    concatenated array can be GC'd prematurely. By calling #to_a explicitly,
    we insert it into the Ruby stack so that GC can recognize it and keep it
    around.
    
    There is a fix and backport for this in Ruby, but it may be a while
    before they're released.
    
    h/t to @stanhu for identifying this as a possible root cause and
    supplying a solution.
    5cb6800c
commit_service.rb 19.8 KB