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

Skip to content

Fix missing WB going to too_complex on class/geniv #13696

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

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

jhawthorn
Copy link
Member

@jhawthorn jhawthorn commented Jun 25, 2025

We were creating a new fields object, and then inserting into it without a write barrier.

I was looking into this because of this CI failure: https://rubyci.s3.amazonaws.com/debian11/ruby-master/log/20250624T213003Z.fail.html.gz

/home/chkbuild/chkbuild/tmp/build/20250624T213003Z/ruby/test/openssl/utils.rb:234: [BUG] try to mark T_NONE object
ruby 3.5.0dev (2025-06-24T20:41:45Z master 3b602c952d) +PRISM [x86_64-linux]

When running OpenSSL::TestSSL, wbcheck reports:

OpenSSL::TestSSL#test_tlsext_hostname
WBCHECK ERROR: Missed write barrier detected!
  Parent object: 0x7ce8b3a390c0 (wb_protected: true)
    rb_obj_info_dump: 0x00007ce8b3a390c0 T_IMEMO/<fields>
  Reference counts - snapshot: 1, writebarrier: 1, current: 4, missed: 2
  Missing reference to: 0x7c08b4110750
    rb_obj_info_dump: 0x00007c08b4110750 OpenSSL/X509/OpenSSL::X509::Certificate OpenSSL/X509
  Missing reference to: 0x7c08b4128dd0
    rb_obj_info_dump: 0x00007c08b4128dd0 OpenSSL/EVP_PKEY/OpenSSL::PKey::RSA OpenSSL/EVP_PKEY

Another thing I noticed is that in some other cases (for T_OBJECT?), we're allocating an st_table first and only after assigning it to the object. That might be fine, but I wonder if that could fail under autocompact. I kept this building the table first and then inserting with a writebarrier after for that reason.

cc @byroot

@jhawthorn jhawthorn changed the title Fix missing write barrier when on too_complex Fix missing WB going to too_complex on class/geniv Jun 25, 2025
@jhawthorn jhawthorn force-pushed the wbcheck_fields_complex branch from 8d129d8 to f4cc803 Compare June 25, 2025 04:03
Copy link

launchable-app bot commented Jun 25, 2025

Tests Failed

✖️no tests failed ✔️62040 tests passed(1 flake)

@byroot
Copy link
Member

byroot commented Jun 25, 2025

we're allocating an st_table first and only after assigning it to the object. That might be fine, but I wonder if that could fail under autocompact.

It's supposed to be fine because the table is created with the right size, so it's not supposed to allocate.

variable.c Outdated

RUBY_ASSERT(!st_lookup(table, (st_data_t)key, NULL));
st_add_direct(table, (st_data_t)key, (st_data_t)val);
RB_OBJ_WRITTEN(fields, Qundef, key);
Copy link
Member

Choose a reason for hiding this comment

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

The key is an ID so it doesn't need a write barrier AFAIK.

We were creating a new fields object, and then inserting into it without
a write barrier.

    OpenSSL::TestSSL#test_tlsext_hostname
    WBCHECK ERROR: Missed write barrier detected!
      Parent object: 0x7ce8b3a390c0 (wb_protected: true)
        rb_obj_info_dump: 0x00007ce8b3a390c0 T_IMEMO/<fields>
      Reference counts - snapshot: 1, writebarrier: 1, current: 4, missed: 2
      Missing reference to: 0x7c08b4110750
        rb_obj_info_dump: 0x00007c08b4110750 OpenSSL/X509/OpenSSL::X509::Certificate OpenSSL/X509
      Missing reference to: 0x7c08b4128dd0
        rb_obj_info_dump: 0x00007c08b4128dd0 OpenSSL/EVP_PKEY/OpenSSL::PKey::RSA OpenSSL/EVP_PKEY
@byroot byroot force-pushed the wbcheck_fields_complex branch from af5453c to 98eba25 Compare June 25, 2025 07:34
@byroot byroot merged commit 3632395 into ruby:master Jun 25, 2025
87 of 89 checks passed
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.

2 participants