Skip to content
  • nagachika's avatar
    cd4a997e
    merge revision(s)... · cd4a997e
    nagachika authored
    merge revision(s) 548086b3,3dc8cde7,e0cf80d6: [Backport #19529]
    
    	ObjectSpace::WeakMap: fix compaction support
    
    	[Bug #19529]
    
    	`rb_gc_update_tbl_refs` can't be used on `w->obj2wmap` because it's
    	not a `VALUE -> VALUE` table, but a `VALUE -> VALUE *` table, so
    	we need some dedicated iterator.
    	---
    	 test/ruby/test_weakmap.rb |  8 ++++++++
    	 weakmap.c                 | 37 ++++++++++++++++++++++++++++++++++++-
    	 2 files changed, 44 insertions(+), 1 deletion(-)
    
    	Fix crash during compaction
    
    	[Bug #19529]
    
    	The fix for [Bug #19529] in commit 548086b3 contained a bug that crashes
    	on the following script:
    
    	```
    	wm = ObjectSpace::WeakMap.new
    	obj = Object.new
    	100.times do
    	  wm[Object.new] = obj
    	  GC.start
    	end
    	GC.compact
    	```
    	---
    	 test/ruby/test_weakmap.rb | 10 ++++++++++
    	 weakmap.c                 |  2 +-
    	 2 files changed, 11 insertions(+), 1 deletion(-)
    
    	Fix incorrect size of WeakMap buffer
    
    	In wmap_final_func, j is the number of elements + 1 (since j also
    	includes the length at the 0th index), so we should resize the buffer
    	to size j and the new length is j - 1.
    	---
    	 weakmap.c | 4 ++--
    	 1 file changed, 2 insertions(+), 2 deletions(-)
    cd4a997e
    merge revision(s)...
    nagachika authored
    merge revision(s) 548086b3,3dc8cde7,e0cf80d6: [Backport #19529]
    
    	ObjectSpace::WeakMap: fix compaction support
    
    	[Bug #19529]
    
    	`rb_gc_update_tbl_refs` can't be used on `w->obj2wmap` because it's
    	not a `VALUE -> VALUE` table, but a `VALUE -> VALUE *` table, so
    	we need some dedicated iterator.
    	---
    	 test/ruby/test_weakmap.rb |  8 ++++++++
    	 weakmap.c                 | 37 ++++++++++++++++++++++++++++++++++++-
    	 2 files changed, 44 insertions(+), 1 deletion(-)
    
    	Fix crash during compaction
    
    	[Bug #19529]
    
    	The fix for [Bug #19529] in commit 548086b3 contained a bug that crashes
    	on the following script:
    
    	```
    	wm = ObjectSpace::WeakMap.new
    	obj = Object.new
    	100.times do
    	  wm[Object.new] = obj
    	  GC.start
    	end
    	GC.compact
    	```
    	---
    	 test/ruby/test_weakmap.rb | 10 ++++++++++
    	 weakmap.c                 |  2 +-
    	 2 files changed, 11 insertions(+), 1 deletion(-)
    
    	Fix incorrect size of WeakMap buffer
    
    	In wmap_final_func, j is the number of elements + 1 (since j also
    	includes the length at the 0th index), so we should resize the buffer
    	to size j and the new length is j - 1.
    	---
    	 weakmap.c | 4 ++--
    	 1 file changed, 2 insertions(+), 2 deletions(-)
Loading