Skip to content

Constants defined in C extensions might be attributed other the gems#2555

Merged
paracycle merged 1 commit intomainfrom
uk-fix-erb-escape
Mar 26, 2026
Merged

Constants defined in C extensions might be attributed other the gems#2555
paracycle merged 1 commit intomainfrom
uk-fix-erb-escape

Conversation

@paracycle
Copy link
Member

Motivation

Some constants like ERB::Escape that are defind in C extension components of gems are currently failing the defined_in_gem? look up.

This happens for ERB::Escape because, instead of erb/lib/erb/utils.rb loading the shared-object for escape, we have erubi loading it. Thus, when we do the backtrace scan to find the file that is loading the constant we attribute it to the erubi gem. This is because there are no frames in the backtrace for the class definition coming from a C extension, thus we miss the actual file that does the ERB::Escape definition.

Implementation

Since we can look up the source location of constants now, it makes more sense to include that in the list of file candidate locations. Which makes it resilient against these kinds of mistakes.

Tests

No added tests

@paracycle paracycle requested a review from a team as a code owner March 25, 2026 23:32
@paracycle paracycle requested review from st0012 and vinistock and removed request for st0012 March 25, 2026 23:32
Some constants like `ERB::Escape` that are defind in C extension
components of gems are currently failing the `defined_in_gem?` look up.

This happens for `ERB::Escape` because, instead of
`erb/lib/erb/utils.rb` loading the shared-object for `escape`, we have
`erubi` loading it. Thus, when we do the backtrace scan to find the file
that is loading the constant we attribute it to the `erubi` gem. This is
because there are no frames in the backtrace for the class definition
coming from a C extension, thus we miss the actual file that does the
`ERB::Escape` definition.

Since we can look up the source location of constants now, it makes more
sense to include that in the list of file candidate locations. Which
makes it resilient against these kinds of mistakes.
@paracycle paracycle merged commit b8ee369 into main Mar 26, 2026
19 of 20 checks passed
@paracycle paracycle deleted the uk-fix-erb-escape branch March 26, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants