Skip to content

Backport string deduplication fixes from 9.3#7021

Merged
headius merged 5 commits intojruby:jruby-9.2from
headius:no_dedup_tainted_9.2
Jan 20, 2022
Merged

Backport string deduplication fixes from 9.3#7021
headius merged 5 commits intojruby:jruby-9.2from
headius:no_dedup_tainted_9.2

Conversation

@headius
Copy link
Member

@headius headius commented Jan 20, 2022

This PR combines the following commits, cherry-picked to the 9.2 branch:

* Always freeze and dedup, even if already frozen
* Dup first if not "bare" (without ivars and with String class)
This is different in Ruby 3.0, which appears to deduplicate and
return a new string always. The 3.0 behavior will need to be
preserved in JRuby 9.4.
We use the same table to store the infrequently used object_id,
FFI native pointer reference, and ObjectSpace weakref-manager
objects. When these are the only variables on a given type, any
allocated ivar table will only be large enough to contain these
values. However when the type in question has had a Ruby instance
variable assigned anywhere in the system, all future variable
tables will be sized to handle both the internal variable and the
instance variables, whether or not the instance variables have
been set. This results in future objects looking like they have
instance variables even if they only have internal variables.

This change scans the variable table list, skipping internal
variables, to see if any instance variables have actually been
set. This allows the instance variable check for interned strings
to work properly when some other string in the system received an
instance variable.
* Check for tainting during deduplication and skip interning if
  tainted.

Fixes jruby#7018

Backported to 9.2 from 9.3 via 59f08d5
minus hash key deduplication not present in Ruby 2.5.
@headius headius added this to the JRuby 9.2.21.0 milestone Jan 20, 2022
@headius
Copy link
Member Author

headius commented Jan 20, 2022

This also fixes #7018 for 9.2.21.0.

* Frozen strings are not deduplicated in Ruby 2.5.
* Cherry-pick of eb11c5d brought
  along this behavior.

See jruby#7021
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.

New string literals are marked as tainted if previously equal tainted strings were read from a file

1 participant