Skip to content

Mask object addresses in message assertions - #82

Open
hsbt wants to merge 1 commit into
masterfrom
mask-object-addresses
Open

Mask object addresses in message assertions#82
hsbt wants to merge 1 commit into
masterfrom
mask-object-addresses

Conversation

@hsbt

@hsbt hsbt commented Sep 10, 2026

Copy link
Copy Markdown
Member

Eight tests in test/test_error_highlight.rb fail intermittently under a moving GC. The expected message heredoc evaluates the receiver's #inspect at the call site and bakes in the object address, but the actual message is only built later, when #message runs inside the block. A GC that relocates the receiver in that window makes the two addresses disagree. Seven of them keep a singleton on the receiver, so name_err_mesg_to_str takes the rb_any_to_s branch and prints an address regardless of the message format. test_local_variable_get reaches the same place through rb_inspect on a Binding.

I normalize both sides in assert_error_message through a new mask_addresses, which rewrites 0x\h+ to 0xXXXX. Doing it in the helper covers all eight sites and any future assertion of the same shape, so the individual #inspect calls stay as they are.

Forcing the relocation with GC.verify_compaction_references fails all eight before the change and none after. This is a forward-port of ruby/ruby#18731, and the file stays byte-identical to test/error_highlight/test_error_highlight.rb upstream.

Generated with Claude Code

The expected message bakes the receiver's `#inspect` into a heredoc before the
block raises, so a moving GC that relocates the receiver in between makes the
two addresses disagree. That is why these tests fail intermittently under MMTk.
`GC.verify_compaction_references` reproduces the same failure with the default
GC.

ruby/ruby#18731

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant