Skip to content
  • John Hawthorn's avatar
    7866e124
    Use rb_current_ec_noinline in assertions · 7866e124
    John Hawthorn authored
    When doing a coroutine transfer from one thread to another, there's a
    risk that the compiler will reuse an address from TLS before the
    transfer to the new thread.
    
    These VM assertions are all in places we would not otherwise be reading
    from TLS, but using the value of `ec` or `cr` passed in. Switching these
    to test against rb_current_ec_noinline() instead ensures there isn't an
    optimization applied to how we read ruby_current_ec.
    
    Currently it seems we were hitting this on LLVM 18 specifically, but I
    don't know of any reason other versions wouldn't have the same issue.
    7866e124
    Use rb_current_ec_noinline in assertions
    John Hawthorn authored
    When doing a coroutine transfer from one thread to another, there's a
    risk that the compiler will reuse an address from TLS before the
    transfer to the new thread.
    
    These VM assertions are all in places we would not otherwise be reading
    from TLS, but using the value of `ec` or `cr` passed in. Switching these
    to test against rb_current_ec_noinline() instead ensures there isn't an
    optimization applied to how we read ruby_current_ec.
    
    Currently it seems we were hitting this on LLVM 18 specifically, but I
    don't know of any reason other versions wouldn't have the same issue.
Loading