* [ruby-core:119738] [Ruby master Bug#20868] Method#hash changes after compaction
@ 2024-11-05 15:55 peterzhu2118 (Peter Zhu) via ruby-core
2024-11-10 4:06 ` [ruby-core:119870] " nagachika (Tomoyuki Chikanaga) via ruby-core
2025-01-15 1:40 ` [ruby-core:120676] " k0kubun (Takashi Kokubun) via ruby-core
0 siblings, 2 replies; 3+ messages in thread
From: peterzhu2118 (Peter Zhu) via ruby-core @ 2024-11-05 15:55 UTC (permalink / raw)
To: ruby-core; +Cc: peterzhu2118 (Peter Zhu)
Issue #20868 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #20868: Method#hash changes after compaction
https://bugs.ruby-lang.org/issues/20868
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
Fix: https://github.com/ruby/ruby/pull/12004
The hash value of a Method may change after a compaction but must remain constant because otherwise it may not work as the key in a hash table.
For example:
```ruby
def a; end
# Need this method here because otherwise the iseq may be on the C stack
# which would get pinned and not move during compaction
def get_hash
method(:a).hash
end
puts get_hash # => 2993401401091578131
GC.verify_compaction_references(expand_heap: true, toward: :empty)
puts get_hash # => -2162775864511574135
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:119870] [Ruby master Bug#20868] Method#hash changes after compaction
2024-11-05 15:55 [ruby-core:119738] [Ruby master Bug#20868] Method#hash changes after compaction peterzhu2118 (Peter Zhu) via ruby-core
@ 2024-11-10 4:06 ` nagachika (Tomoyuki Chikanaga) via ruby-core
2025-01-15 1:40 ` [ruby-core:120676] " k0kubun (Takashi Kokubun) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: nagachika (Tomoyuki Chikanaga) via ruby-core @ 2024-11-10 4:06 UTC (permalink / raw)
To: ruby-core; +Cc: nagachika (Tomoyuki Chikanaga)
Issue #20868 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 3.1: WONTFIX, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: WONTFIX, 3.2: DONE, 3.3: REQUIRED
ruby_3_2 commit:ee3428aa0e3a11ed1574b7d99222f6f08737f818 merged revision(s) commit:56ecc243e230e8e99761ec0ffc5116601f094bb0.
----------------------------------------
Bug #20868: Method#hash changes after compaction
https://bugs.ruby-lang.org/issues/20868#change-110561
* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Backport: 3.1: WONTFIX, 3.2: DONE, 3.3: REQUIRED
----------------------------------------
Fix: https://github.com/ruby/ruby/pull/12004
The hash value of a Method may change after a compaction but must remain constant because otherwise it may not work as the key in a hash table.
For example:
```ruby
def a; end
# Need this method here because otherwise the iseq may be on the C stack
# which would get pinned and not move during compaction
def get_hash
method(:a).hash
end
puts get_hash # => 2993401401091578131
GC.verify_compaction_references(expand_heap: true, toward: :empty)
puts get_hash # => -2162775864511574135
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:120676] [Ruby master Bug#20868] Method#hash changes after compaction
2024-11-05 15:55 [ruby-core:119738] [Ruby master Bug#20868] Method#hash changes after compaction peterzhu2118 (Peter Zhu) via ruby-core
2024-11-10 4:06 ` [ruby-core:119870] " nagachika (Tomoyuki Chikanaga) via ruby-core
@ 2025-01-15 1:40 ` k0kubun (Takashi Kokubun) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: k0kubun (Takashi Kokubun) via ruby-core @ 2025-01-15 1:40 UTC (permalink / raw)
To: ruby-core; +Cc: k0kubun (Takashi Kokubun)
Issue #20868 has been updated by k0kubun (Takashi Kokubun).
Backport changed from 3.1: WONTFIX, 3.2: DONE, 3.3: REQUIRED to 3.1: WONTFIX, 3.2: DONE, 3.3: DONE
ruby_3_3 commit:42f043c1893b320b9d2a38ec3b1065dee71ce863 merged revision(s) commit:56ecc243e230e8e99761ec0ffc5116601f094bb0.
----------------------------------------
Bug #20868: Method#hash changes after compaction
https://bugs.ruby-lang.org/issues/20868#change-111499
* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Backport: 3.1: WONTFIX, 3.2: DONE, 3.3: DONE
----------------------------------------
Fix: https://github.com/ruby/ruby/pull/12004
The hash value of a Method may change after a compaction but must remain constant because otherwise it may not work as the key in a hash table.
For example:
```ruby
def a; end
# Need this method here because otherwise the iseq may be on the C stack
# which would get pinned and not move during compaction
def get_hash
method(:a).hash
end
puts get_hash # => 2993401401091578131
GC.verify_compaction_references(expand_heap: true, toward: :empty)
puts get_hash # => -2162775864511574135
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-15 1:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-05 15:55 [ruby-core:119738] [Ruby master Bug#20868] Method#hash changes after compaction peterzhu2118 (Peter Zhu) via ruby-core
2024-11-10 4:06 ` [ruby-core:119870] " nagachika (Tomoyuki Chikanaga) via ruby-core
2025-01-15 1:40 ` [ruby-core:120676] " k0kubun (Takashi Kokubun) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).