Skip to content

Definition#deprecated? returns true for plain constants on x86_64 when built with rustc 1.99.0 #1089

Closed

Description

@bquorning

Note

Update: the cause is a rustc 1.99.0 miscompilation on x86_64 (rust-lang/rust#163911), not ruby-head or the 4.1 headers. See this comment. The original report is kept below for context, and its "Question" section is wrong.

On ruby-head on Linux x86_64, Definition#deprecated? returns true for constants that have no @deprecated tag. Definition identity is intact: location and comments return correct values; only the flag is wrong. The same rubydex builds behave correctly on Ruby 3.2 through 4.0, and on darwin-arm64 ruby-head.

Reproduction

require 'rubydex'

graph = Rubydex::Graph.new
graph.index_source('file:///fixture.rb', "module Fixture\n  STR_CONST = 'x'.freeze\nend\n", 'ruby')
graph.resolve

graph['Fixture'].member('STR_CONST').definitions.first.deprecated?
# ubuntu-24.04 x86_64, ruby-head (4.1.0dev 2026-10-24): true  (wrong)
# Ruby 3.2-4.0 and darwin-arm64 ruby-head:              false (correct)

Notes

  • Wrongly flagged: constants assigned a String, Regexp, Array, Hash, Set, or Pathname. Correct: Integer, Symbol, Float, true, nil, Bignum, Range, and a genuinely @deprecated constant.
  • The wrong value shows on the first query and is unchanged by GC.start + GC.compact. The same fixture written to disk and indexed via index_all fails identically.
  • Both 0.4.1 and 0.4.2 fail from a fresh source install, so this is not a recent rubydex regression.
  • Green on ruby-head 2026-10-17 (ruby/ruby@5b1c373522), red since 2026-10-21 (ruby/ruby@b4ae8a7189, 82 commits), still red on 2026-10-24. Linux x86_64 only; clean on darwin-arm64, including ruby-dev-builder's own prebuilt tarball.
  • Your ci.yml matrix (3.3, 3.4, 4.0) does not test ruby-head, which is why this goes unnoticed. Adding ruby-head should reproduce it in your existing deprecation tests.

Question

deprecated? is computed in Rust at index time, and the definition's location and comments cross into Ruby correctly. Only the flag is wrong, so the corruption must happen in the native extension that bridges Rust and Ruby, which on ruby-head is compiled from source against the 4.1 headers.

Written with the help of Claude Code.

Activity

  1. bquorning commented on Oct 27, 2026

    @bquorning
    Author

    Update: parts of this report are wrong, and I’m still investigating.

    • It isn't specific to ruby-head. On x86_64-linux, the prebuilt 0.4.3 gem shows the bug on stable Ruby 3.4.12 and 4.0.7. 0.4.2 is correct on both.
    • The explanation about compiling against the 4.1 headers is wrong. Prebuilt binaries are affected too.
    • aarch64-linux with 0.4.3 is correct, so it still looks x86_64-only.

    The lockfiles move ruby-prism from 2.0.0-rc.2 in 0.4.2 to 2.0.0 in 0.4.3, so that bump is my main suspect for now. I’ll follow up when I know more.

  2. bquorning commented on Oct 27, 2026

    @bquorning
    Author

    Correction: the cause is a rustc 1.99.0 miscompilation on x86_64 (rust-lang/rust#163911, fixed in 1.99.1). It isn't specific to ruby-head, and the 4.1 headers have nothing to do with it.

    rdx_definition_is_deprecated is missing the and $0x1 before ret, so it returns the raw DefinitionFlags byte. Constants with PROMOTABLE set (e.g. X = 'x'.freeze) then report deprecated? == true.

    • The prebuilt 0.4.3 x86_64-linux gem was built with rustc 1.99.0. 0.4.2 was built with 1.99.1 and is correct. readelf -p .comment librubydex_sys.so shows this.
    • On ruby-head the gem is compiled from source with the CI runner's rustc, which is 1.99.0 on current ubuntu-24.04 images.

    Rebuilding with rustc 1.99.1 or later should fix it. Pinning the toolchain in the release workflow would prevent a repeat.

    Written with the help of Claude Code.

  3. changed the title [-]`Definition#deprecated?` returns true for plain constants on ruby-head (4.1.0dev), Linux x86_64[/-] [+]`Definition#deprecated?` returns true for plain constants on x86_64 when built with rustc 1.99.0[/+] on Oct 27, 2026
  4. added a commit that references this issue on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions