Commit graph

7412 commits

Author SHA1 Message Date
nagachika
e14280fa25 merge revision(s) bde3b98a60:
[Cirrus] Make gem download non-verbose

	---
	 .cirrus.yml | 16 ++++++++--------
	 1 file changed, 8 insertions(+), 8 deletions(-)
2023-07-16 23:20:16 +09:00
nagachika
88cd139992 merge revision(s) 3751349044:
[Cirrus] Cache the bundled gems in advance

	---
	 .cirrus.yml | 19 +++++++++++++++++++
	 1 file changed, 19 insertions(+)
2023-07-16 18:59:17 +09:00
nagachika
bfa04c0362 merge revision(s) 72f07f0a5f:
Reduce concurrency of Cirrus-CI [ci skip]

	clang-12 takes 2-3 times longer than gcc-11.
	---
	 .cirrus.yml | 4 ----
	 1 file changed, 4 deletions(-)
2023-07-16 18:57:45 +09:00
nagachika
c911cbd6c3 merge revision(s) bd786e7896: [Backport #19084]
Fix mutation on shared strings. (#7837)

	---
	 io_buffer.c                 | 19 ++++++++++++-------
	 test/ruby/test_io_buffer.rb |  4 ----
	 2 files changed, 12 insertions(+), 11 deletions(-)
2023-07-16 16:50:13 +09:00
nagachika
5ad2390b55 merge revision(s) 466aa8010f: [Backport #19546]
Fix incorrect usage of `rb_fiber_scheduler_io_(p)(read|write)`.
	 (#7593)

	---
	 io_buffer.c                  |  8 ++++----
	 scheduler.c                  | 48 ++++++++++++++++++++++----------------------
	 test/fiber/test_io_buffer.rb | 33 ++++++++++++++++++++++++++++++
	 3 files changed, 61 insertions(+), 28 deletions(-)
2023-07-16 16:44:22 +09:00
nagachika
c13757ed9a merge revision(s) 09295ea796: [Backport #19543]
IO::Buffer#resize: Free internal buffer if new size is zero (#7569)

	`#resize(0)` on an IO::Buffer with internal buffer allocated will
	result in calling `realloc(data->base, 0)`. The behavior of `realloc`
	with size = 0 is implementation-defined (glibc frees the object
	and returns NULL, while BSDs return an inaccessible object). And
	thus such usage is deprecated in standard C (upcoming C23 will make it
	UB).

	To avoid this problem, just `free`s the memory when the new size is zero.
	---
	 io_buffer.c                 |  5 +++++
	 test/ruby/test_io_buffer.rb | 18 ++++++++++++++++++
	 2 files changed, 23 insertions(+)
2023-07-16 16:42:12 +09:00
nagachika
141402d11c merge revision(s) e1bd45624c: [Backport #19482]
Fix crash when allocating classes with newobj hook

	We need to zero out the whole slot when running the newobj hook for a
	newly allocated class because the slot could be filled with garbage,
	which would cause a crash if a GC runs inside of the newobj hook.

	For example, the following script crashes:

	```
	require "objspace"

	GC.stress = true

	ObjectSpace.trace_object_allocations {
	  100.times do
	    Class.new
	  end
	}
	```

	[Bug #19482]
	---
	 gc.c                           | 8 +++++++-
	 test/objspace/test_objspace.rb | 7 +++++++
	 2 files changed, 14 insertions(+), 1 deletion(-)
2023-07-16 12:58:21 +09:00
nagachika
44a8e5e63a merge revision(s) 833b32f503abb9712dbb3a6825b1730c8ee1e912,1dde9d726099fc4e4b06b8c848c85eac195c521b:
also disable yjit for clang < 10

	They don't compile.  I guess nobody actively maintain such old
	compilers.  Chances are the situation won't improve.  Let's stop
	testing yjit on them.
	---
	 .github/workflows/compilers.yml | 8 ++++----
	 1 file changed, 4 insertions(+), 4 deletions(-)

	Explain why YJIT is disabled for clang<=9 [ci skip]

	---
	 .github/workflows/compilers.yml | 1 +
	 1 file changed, 1 insertion(+)
2023-07-16 11:46:12 +09:00
nagachika
b13db31ce8 merge revision(s) fe42d88ad2:
Pass -Werror=lto-type-mismatch for GCC LTO jobs

	This helps to find possible LTO miscompilations earlier. See also
	https://github.com/ruby/ruby/pull/7695.
	---
	 .github/workflows/compilers.yml | 12 ++++++------
	 1 file changed, 6 insertions(+), 6 deletions(-)
2023-07-16 11:46:04 +09:00
nagachika
3e664c5813 merge revision(s) 27a21ad201:
give up checking old compilers

	These old compilers needed old OSes, which are getting EODed.  We
	cannot maintain healthy binary of them (building compilers on our
	own is quite haed).  Let us just retire them.  Fixes [Bug #19353]
	---
	 .github/workflows/compilers.yml | 6 ------
	 1 file changed, 6 deletions(-)
2023-07-16 11:43:54 +09:00
nagachika
eeb4fc2cf8 merge revision(s) dd7c590f8a4dafbc0d659d07645aea59586b0f70,6a871baa3cd759c0eba361b4937eeca531513a09:
disable yjit when for non-flonum

	YJIT does not interface with this flag.
	---
	 .github/workflows/compilers.yml | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)

	Note that YJIT requires FLONUM [ci skip]

	---
	 .github/workflows/compilers.yml | 6 +++++-
	 1 file changed, 5 insertions(+), 1 deletion(-)
2023-07-16 11:36:59 +09:00
nagachika
293a00e622 merge revision(s) 33edcc112081f96856d52e73253d73c97a5c4a3c,b4e438d8aabaf4bba2b27f374c787543fae07c58: [Backport #19483]
YJIT: Protect strings from GC on String#<< (#7466)

	Fix https://github.com/Shopify/yjit/issues/310

	[Bug #19483]

	Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
	Co-authored-by: Jimmy Miller <jimmy.miller@shopify.com>
	---
	 yjit/src/codegen.rs | 3 +++
	 1 file changed, 3 insertions(+)

	YJIT: Save PC on rb_str_concat (#7586)

	[Bug #19483]

	Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/codegen.rs    |  6 ++++--
	 2 files changed, 23 insertions(+), 2 deletions(-)
2023-07-16 11:25:45 +09:00
nagachika
0ba10fd850 merge revision(s) 132934b82b: [Backport #19463]
YJIT: Generate Block::entry_exit with block entry PC

	Previously, when Block::entry_exit is requested from any instruction
	that is not the first one in the block, we generated the exit with an
	incorrect PC. We should always be using the PC for the entry of the
	block for Block::entry_exit.

	It was a simple typo. The bug was [introduced][1] while we were
	refactoring to use the current backend. Later, we had a chance to spot
	this issue while [preparing][2] to enable unused variable warnings, but
	didn't spot the issue.

	Fixes [Bug #19463]

	[1]: 27fcab995e
	[2]: 31461c7e0e
	---
	 test/ruby/test_yjit.rb | 41 +++++++++++++++++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  4 ++--
	 2 files changed, 43 insertions(+), 2 deletions(-)
2023-07-16 11:25:45 +09:00
nagachika
07d5709fee bump patchlevel 2023-07-01 14:18:06 +09:00
nagachika
814271b2f7 bump patchlevel 2023-07-01 13:48:08 +09:00
nagachika
b422c3523c merge revision(s) 7bd7aee02e: [Backport #18464]
Fix interpreter crash caused by RUBY_INTERNAL_EVENT_NEWOBJ + Ractors

	When a Ractor is created whilst a tracepoint for
	RUBY_INTERNAL_EVENT_NEWOBJ is active, the interpreter crashes. This is
	because during the early setup of the Ractor, the stdio objects are
	created, which allocates Ruby objects, which fires the tracepoint.
	However, the tracepoint machinery tries to dereference the control frame
	(ec->cfp->pc), which isn't set up yet and so crashes with a null pointer
	dereference.

	Fix this by not firing GC tracepoints if cfp isn't yet set up.
	---
	 gc.c                         |  1 +
	 test/objspace/test_ractor.rb | 17 +++++++++++++++++
	 2 files changed, 18 insertions(+)
	 create mode 100644 test/objspace/test_ractor.rb
2023-06-25 15:20:43 +09:00
nagachika
0c00fb5d92 merge revision(s) ec14861f0d:
Update to ruby/spec@7e680fa

	---
	 spec/ruby/core/dir/home_spec.rb      | 5 +++--
	 spec/ruby/core/process/spawn_spec.rb | 2 +-
	 2 files changed, 4 insertions(+), 3 deletions(-)
2023-06-25 12:37:14 +09:00
nagachika
e3d10dedf1 merge revision(s) bffadcd6d4: [Backport #19529]
Add guard to compaction test in WeakMap

	Some platforms don't support compaction, so we should skip this test.
	---
	 test/ruby/test_weakmap.rb | 2 ++
	 1 file changed, 2 insertions(+)
2023-06-25 12:29:49 +09:00
nagachika
3ebcbb537d merge revision(s) 548086b34e3dd125edabf5dc1e46b891fad3ea9c,3dc8cde70078ccb38f5f4b0818ad5eecded01bd5,e0cf80d666d4b5df3229f030a16d10d21323508e: [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 548086b 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(-)
2023-06-25 12:26:20 +09:00
nagachika
a048f7882a merge revision(s) 1cdf8ab07b: [Backport #19323]
[Bug #19323] Raise `RangeError` instead of integer overflow

	---
	 bignum.c                  |  5 ++++-
	 test/ruby/test_integer.rb | 18 ++++++++----------
	 2 files changed, 12 insertions(+), 11 deletions(-)
2023-06-25 11:52:21 +09:00
nagachika
9fca561980 merge revision(s) cd5e6cc0ea48353c88d921b885b552dc76da255c,bbf54ec334fe2edd7669a944d88d17efde49a412: [Backport #19307]
Update to ruby/mspec@fef9b81

	---
	 spec/mspec/tool/tag_from_output.rb | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)

	Update to ruby/spec@9d69b95

	---
	 spec/ruby/core/array/keep_if_spec.rb               |   1 +
	 spec/ruby/core/array/pack/c_spec.rb                |  14 +-
	 spec/ruby/core/array/pack/shared/basic.rb          |  40 ++++
	 spec/ruby/core/array/pack/shared/float.rb          |  66 ++++++-
	 spec/ruby/core/array/pack/shared/integer.rb        |  96 +++++++--
	 spec/ruby/core/array/pack/shared/numeric_basic.rb  |  10 +-
	 spec/ruby/core/array/pack/shared/unicode.rb        |  14 +-
	 spec/ruby/core/array/pack/w_spec.rb                |  14 +-
	 spec/ruby/core/array/shared/unshift.rb             |  18 ++
	 spec/ruby/core/array/values_at_spec.rb             |   1 +
	 spec/ruby/core/array/zip_spec.rb                   |   6 +
	 spec/ruby/core/class/subclasses_spec.rb            |  22 +++
	 spec/ruby/core/dir/home_spec.rb                    |  44 +++--
	 spec/ruby/core/dir/mkdir_spec.rb                   |  18 +-
	 spec/ruby/core/enumerable/zip_spec.rb              |   5 +
	 spec/ruby/core/float/comparison_spec.rb            |  35 ++--
	 spec/ruby/core/float/divmod_spec.rb                |   2 +-
	 spec/ruby/core/float/gt_spec.rb                    |  21 ++
	 spec/ruby/core/float/gte_spec.rb                   |  21 ++
	 spec/ruby/core/float/lt_spec.rb                    |  21 ++
	 spec/ruby/core/float/lte_spec.rb                   |  21 ++
	 spec/ruby/core/float/shared/equal.rb               |  21 ++
	 spec/ruby/core/io/gets_spec.rb                     |   4 +
	 spec/ruby/core/io/lineno_spec.rb                   |   9 +-
	 spec/ruby/core/io/new_spec.rb                      |   2 +
	 spec/ruby/core/io/readline_spec.rb                 |   4 +
	 spec/ruby/core/io/readlines_spec.rb                |   4 +
	 spec/ruby/core/io/shared/each.rb                   |   4 +
	 spec/ruby/core/io/shared/new.rb                    |   2 +
	 spec/ruby/core/io/shared/pos.rb                    |   8 +-
	 spec/ruby/core/io/shared/readlines.rb              |   4 +
	 spec/ruby/core/io/sysseek_spec.rb                  |   2 +-
	 spec/ruby/core/kernel/shared/load.rb               |  31 ++-
	 spec/ruby/core/kernel/singleton_class_spec.rb      |   2 +
	 spec/ruby/core/marshal/dump_spec.rb                |  45 ++++-
	 spec/ruby/core/marshal/fixtures/classes.rb         |   4 +
	 spec/ruby/core/matchdata/values_at_spec.rb         |  73 ++++++-
	 spec/ruby/core/module/fixtures/classes.rb          |   1 +
	 spec/ruby/core/module/include_spec.rb              |   4 +-
	 spec/ruby/core/module/prepend_spec.rb              |  12 ++
	 .../ruby/core/objectspace/define_finalizer_spec.rb |  22 +++
	 spec/ruby/core/process/constants_spec.rb           |   1 +
	 spec/ruby/core/process/detach_spec.rb              |  29 +++
	 spec/ruby/core/process/spawn_spec.rb               |  10 +
	 spec/ruby/core/process/times_spec.rb               |   2 +-
	 spec/ruby/core/queue/initialize_spec.rb            |  13 +-
	 spec/ruby/core/refinement/import_methods_spec.rb   |  34 ++++
	 spec/ruby/core/refinement/include_spec.rb          |  27 +++
	 spec/ruby/core/refinement/prepend_spec.rb          |  27 +++
	 spec/ruby/core/regexp/initialize_spec.rb           |   2 +-
	 spec/ruby/core/signal/trap_spec.rb                 |  12 ++
	 spec/ruby/core/string/byteslice_spec.rb            |   6 +
	 spec/ruby/core/string/capitalize_spec.rb           |   4 +
	 spec/ruby/core/string/chars_spec.rb                |   7 +-
	 spec/ruby/core/string/chomp_spec.rb                |   4 +
	 spec/ruby/core/string/chop_spec.rb                 |   4 +
	 spec/ruby/core/string/clone_spec.rb                |   4 +
	 spec/ruby/core/string/delete_prefix_spec.rb        |   4 +
	 spec/ruby/core/string/delete_spec.rb               |   4 +
	 spec/ruby/core/string/delete_suffix_spec.rb        |   4 +
	 spec/ruby/core/string/downcase_spec.rb             |   4 +
	 spec/ruby/core/string/dump_spec.rb                 |  10 +-
	 spec/ruby/core/string/dup_spec.rb                  |   4 +
	 spec/ruby/core/string/lines_spec.rb                |   1 -
	 spec/ruby/core/string/reverse_spec.rb              |   4 +
	 spec/ruby/core/string/scan_spec.rb                 |   6 +
	 spec/ruby/core/string/scrub_spec.rb                |  10 +
	 spec/ruby/core/string/shared/each_line.rb          |   6 +
	 spec/ruby/core/string/shared/partition.rb          |  15 ++
	 spec/ruby/core/string/shared/slice.rb              |  13 +-
	 spec/ruby/core/string/shared/strip.rb              |   4 +
	 spec/ruby/core/string/shared/succ.rb               |   4 +
	 spec/ruby/core/string/split_spec.rb                |  17 +-
	 spec/ruby/core/string/squeeze_spec.rb              |   5 +
	 spec/ruby/core/string/swapcase_spec.rb             |   4 +
	 spec/ruby/core/string/undump_spec.rb               |   2 +-
	 spec/ruby/core/string/unpack/b_spec.rb             |  28 ++-
	 spec/ruby/core/string/unpack/c_spec.rb             |  14 +-
	 spec/ruby/core/string/unpack/h_spec.rb             |  28 ++-
	 spec/ruby/core/string/unpack/shared/basic.rb       |  28 ---
	 spec/ruby/core/string/unpack/shared/float.rb       |  60 +++++-
	 spec/ruby/core/string/unpack/shared/integer.rb     |  88 +++++++--
	 spec/ruby/core/string/unpack/shared/unicode.rb     |  14 +-
	 spec/ruby/core/string/unpack/w_spec.rb             |  14 +-
	 spec/ruby/core/string/unpack1_spec.rb              |  12 +-
	 spec/ruby/core/string/unpack_spec.rb               |  34 ++++
	 spec/ruby/core/string/upcase_spec.rb               |   4 +
	 spec/ruby/core/string/valid_encoding/utf_8_spec.rb | 214 +++++++++++++++++++++
	 spec/ruby/core/struct/values_at_spec.rb            |  55 +++++-
	 spec/ruby/core/symbol/shared/id2name.rb            |   7 +
	 spec/ruby/core/time/at_spec.rb                     |  16 ++
	 spec/ruby/core/time/localtime_spec.rb              |  16 +-
	 spec/ruby/core/time/new_spec.rb                    |  94 +++++++--
	 spec/ruby/core/time/shared/gmtime.rb               |   4 +-
	 spec/ruby/core/time/shared/time_params.rb          |  11 +-
	 spec/ruby/core/time/strftime_spec.rb               |  40 +++-
	 spec/ruby/core/time/utc_spec.rb                    |  41 +++-
	 spec/ruby/core/time/zone_spec.rb                   |  20 +-
	 spec/ruby/core/tracepoint/inspect_spec.rb          |   9 +
	 spec/ruby/fixtures/code/load_wrap_fixture.rb       |  12 ++
	 spec/ruby/fixtures/code/wrap_fixture.rb            |   9 -
	 spec/ruby/language/case_spec.rb                    |   4 +-
	 .../ruby/language/regexp/character_classes_spec.rb |   5 +
	 spec/ruby/library/coverage/running_spec.rb         |  20 ++
	 spec/ruby/library/date/civil_spec.rb               |   7 +-
	 spec/ruby/library/objectspace/fixtures/trace.rb    |   5 +
	 spec/ruby/library/objectspace/trace_spec.rb        |  15 ++
	 spec/ruby/library/openssl/x509/name/verify_spec.rb |   4 +-
	 spec/ruby/library/stringio/initialize_spec.rb      |  85 ++++++++
	 spec/ruby/library/stringio/new_spec.rb             |   8 +
	 spec/ruby/library/stringio/shared/write.rb         |  22 +++
	 spec/ruby/optional/capi/ext/io_spec.c              |  43 +++++
	 spec/ruby/optional/capi/io_spec.rb                 |  15 ++
	 spec/ruby/shared/rational/Rational.rb              |  48 ++---
	 114 files changed, 1963 insertions(+), 245 deletions(-)
	 create mode 100644 spec/ruby/core/marshal/fixtures/classes.rb
	 create mode 100644 spec/ruby/core/refinement/import_methods_spec.rb
	 create mode 100644 spec/ruby/core/refinement/include_spec.rb
	 create mode 100644 spec/ruby/core/refinement/prepend_spec.rb
	 create mode 100644 spec/ruby/core/string/unpack_spec.rb
	 create mode 100644 spec/ruby/core/string/valid_encoding/utf_8_spec.rb
	 create mode 100644 spec/ruby/fixtures/code/load_wrap_fixture.rb
	 delete mode 100644 spec/ruby/fixtures/code/wrap_fixture.rb
	 create mode 100644 spec/ruby/library/coverage/running_spec.rb
	 create mode 100644 spec/ruby/library/objectspace/fixtures/trace.rb
	 create mode 100644 spec/ruby/library/objectspace/trace_spec.rb
	 create mode 100644 spec/ruby/library/stringio/new_spec.rb
2023-06-24 16:59:30 +09:00
NARUSE, Yui
e51014f9c0 v3.2.2p53 2023-03-30 20:06:29 +09:00
NARUSE, Yui
936b705d78 v3.2.1p53 2023-03-30 20:05:11 +09:00
NARUSE, Yui
582aadb390 merge revision(s) 2f916812a9b818b432ee7c299e021ec62d4727fb,ac458f6bc3c520c9f23364c85bfb033acda907a6:
Skip test_europe_lisbon on macOS

	until we figure out why it's failing.
	---
	 test/ruby/test_time_tz.rb | 1 +
	 1 file changed, 1 insertion(+)

	Historical timezones of Lisbon in tzdata are unstable

	---
	 test/ruby/test_time_tz.rb | 3 +--
	 1 file changed, 1 insertion(+), 2 deletions(-)
2023-03-28 17:02:53 +09:00
NARUSE, Yui
fb4ffce0dd merge revision(s) 680bd9027f: [Backport #19471]
[Bug #19471] `Regexp.compile` should handle keyword arguments

	As well as `Regexp.new`, it should pass keyword arguments to the
	`Regexp#initialize` method.
	---
	 re.c                     | 2 +-
	 test/ruby/test_regexp.rb | 5 +++++
	 2 files changed, 6 insertions(+), 1 deletion(-)
2023-03-28 14:25:13 +09:00
NARUSE, Yui
b93e222330 merge revision(s) e7342e76df: [Backport #19485]
[Bug #19485] [DOC] Mention tabs in indentation of heredoc identifier

	Co-Authored-By: sawa (Tsuyoshi Sawada) <sawadatsuyoshi@gmail.com>
	---
	 doc/syntax/literals.rdoc | 6 ++++++
	 1 file changed, 6 insertions(+)
2023-03-23 12:04:46 +09:00
NARUSE, Yui
400ccb16ee merge revision(s) cb22d78354: [Backport #19536]
Fix frozen status loss when moving objects

	[Bug #19536]

	When objects are moved between size pools, their frozen status is lost
	in the shape. This will cause the frozen check to be bypassed when there
	is an inline cache. For example, the following script should raise a
	FrozenError, but doesn't on Ruby 3.2 and master.

	    class A
	      def add_ivars
	        @a = @b = @c = @d = 1
	      end

	      def set_a
	        @a = 10
	      end
	    end

	    a = A.new
	    a.add_ivars
	    a.freeze

	    b = A.new
	    b.add_ivars
	    b.set_a # Set the inline cache in set_a

	    GC.verify_compaction_references(expand_heap: true, toward: :empty)

	    a.set_a
	---
	 shape.c                      |  2 +-
	 test/ruby/test_gc_compact.rb | 28 ++++++++++++++++++++++++++++
	 2 files changed, 29 insertions(+), 1 deletion(-)
2023-03-23 08:11:23 +09:00
NARUSE, Yui
ad6fe84dfa merge revision(s) dddc542e9b: [Backport #19476]
[Bug #19476]: correct cache index computation for repetition (#7457)

	---
	 regexec.c                | 4 ++--
	 test/ruby/test_regexp.rb | 5 +++++
	 2 files changed, 7 insertions(+), 2 deletions(-)
2023-03-22 10:34:12 +09:00
NARUSE, Yui
4b4087dce3 merge revision(s) e22c4e8877: [Backport #19467]
[Bug #19467] correct cache points and counting failure on
	 `OP_ANYCHAR_STAR_PEEK_NEXT` (#7454)

	---
	 regexec.c                | 20 ++++++++++++++++----
	 test/ruby/test_regexp.rb | 10 ++++++++++
	 2 files changed, 26 insertions(+), 4 deletions(-)
2023-03-20 15:06:34 +09:00
NARUSE, Yui
0555303464 merge revision(s) 96d1acfdf6: [Backport #19161]
[Bug #19161] Check for TLS usability

	On all platforms using GCC, even other than darwin.
	---
	 configure.ac | 13 +++++++------
	 1 file changed, 7 insertions(+), 6 deletions(-)
2023-03-18 15:02:04 +09:00
NARUSE, Yui
f3abe5ba64 merge revision(s) 0700d0fd1c77b4fddf803dea3c10be654df600ff,62c2082f1f726cb90d8c332fbedbecf41d5d82ec: [Backport #19469]
Fix indentation in vm_setivar_default

	---
	 vm_insnhelper.c | 6 +++---
	 1 file changed, 3 insertions(+), 3 deletions(-)

	[Bug #19469] Fix crash when resizing generic iv list

	The following script can sometimes trigger a crash:

	```ruby
	GC.stress = true

	class Array
	  def foo(bool)
	    if bool
	      @a = 1
	      @b = 2
	      @c = 1
	    else
	      @c = 1
	    end
	  end
	end

	obj = []
	obj.foo(true)

	obj2 = []
	obj2.foo(false)

	obj3 = []
	obj3.foo(true)
	```

	This is because vm_setivar_default calls rb_ensure_generic_iv_list_size
	to resize the iv list. However, the call to gen_ivtbl_resize reallocs
	the iv list, and then inserts into the generic iv table. If the
	st_insert triggers a GC then the old iv list will be read during
	marking, causing a use-after-free bug.

	Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
	---
	 internal/variable.h |  2 +-
	 variable.c          | 23 ++++++++++++++++++-----
	 vm_insnhelper.c     |  4 ++--
	 3 files changed, 21 insertions(+), 8 deletions(-)
2023-03-17 13:40:04 +09:00
NARUSE, Yui
b309c246ee merge revision(s) d78ae78fd7: [Backport #19468]
rb_str_modify_expand: clear the string coderange

	[Bug #19468]

	b0b9f7201a errornously stopped
	clearing the coderange.

	Since `rb_str_modify` clears it, `rb_str_modify_expand`
	should too.
	---
	 string.c | 1 +
	 1 file changed, 1 insertion(+)
2023-03-17 10:56:18 +09:00
NARUSE, Yui
b73a073597 merge revision(s) 0eb634ae73: [Backport #19464]
YJIT: Detect and reject `send(:alias_for_send, :foo)`

	Previously, YJIT failed to put the stack into the correct shape when
	`BasicObject#send` calls an alias method for the send method itself.
	This can manifest as strange `NoMethodError`s in the final non-send
	receiver, as [seen][1] with the kt-paperclip gem. I also found a case
	where it makes YJIT fail the stack size assertion while compiling
	`leave`.

	YJIT's `BasicObject#__send__` implementation already rejects sends to
	`send`, but didn't detect sends to aliases of `send`. Adjust the
	detection and reject these cases.

	Fixes [Bug #19464]

	[1]: https://github.com/Shopify/yjit/issues/306
	---
	 test/ruby/test_yjit.rb | 20 ++++++++++++++++++++
	 yjit/src/codegen.rs    | 25 ++++++++++---------------
	 2 files changed, 30 insertions(+), 15 deletions(-)
2023-03-15 16:36:32 +09:00
NARUSE, Yui
db28f7003f merge revision(s) 3b567eb491: [Backport #19459]
[Bug #19459] Remove unnecessary always-true checks (#7362)

	`length` is a required argument for `IO::Buffer#read` and
	`IO::Buffer#write` methods, and `argc` is already checked with
	`rb_check_arity`.  Also fix the call-seq of `IO::Buffer#read`.
	---
	 io_buffer.c | 24 +++++++-----------------
	 1 file changed, 7 insertions(+), 17 deletions(-)
2023-03-09 09:35:39 +09:00
NARUSE, Yui
4e4a4e42b2 merge revision(s) d2520b7b76: [Backport #19439]
Marshal.load: restore instance variables on Regexp

	[Bug #19439]

	The instance variables were restore on the Regexp source,
	not the regexp itself.

	Unfortunately we have a bit of a chicken and egg problem.

	The source holds the encoding, and the encoding need to be set on
	the source to be able to instantiate the Regexp.

	So the instance variables have to be read on the `source`.
	To correct this we transfert the instance variables after
	instantiating the Regexp.

	The only way to avoid this would be to read the instance variable
	twice and rewind.
	---
	 marshal.c                             | 20 ++++++++++++++++++--
	 spec/ruby/core/marshal/shared/load.rb | 11 +++++++++++
	 2 files changed, 29 insertions(+), 2 deletions(-)
2023-03-08 14:46:30 +09:00
NARUSE, Yui
59eb18037f merge revision(s) dd28c55a7c: [Backport #19445]
[Bug#19445] Fix keyword splat in enumerator

	Extracted arguments do not have keyword hash to splat.
	---
	 numeric.c                 | 2 +-
	 test/ruby/test_numeric.rb | 3 +++
	 2 files changed, 4 insertions(+), 1 deletion(-)
2023-03-08 12:02:22 +09:00
NARUSE, Yui
4d75035e17 merge revision(s) c178926fbe879045fa711444a1fd9e906af23e3b,a4b7ec12298c78392797e5ba7704076550e4f100: [Backport #19444]
YJIT: jit_prepare_routine_call() for String#+@ missing

	We saw SEGVs due to this when running with StackProf, which needs a
	correct PC for RUBY_INTERNAL_EVENT_NEWOBJ, the same event used for
	ObjectSpace allocation tracing.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 27 +++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  5 ++++-
	 2 files changed, 31 insertions(+), 1 deletion(-)

	YJIT: Fix false assumption that String#+@ => ::String

	Could return a subclass.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 17 +++++++++++++++++
	 yjit/src/codegen.rs    | 10 +++++++---
	 2 files changed, 24 insertions(+), 3 deletions(-)
2023-03-07 19:48:32 +09:00
NARUSE, Yui
f1cde05d99 merge revision(s) 86de48e9f6: [Backport #19419]
Remove ibf_dumper's WB_PROTECTED status

	It doesn't have the right write barriers in place. For example, there is

	    rb_mark_set(dump->global_buffer.obj_table);

	in the mark function, but there is no corresponding write barrier when
	adding to the table in the
	`ibf_dump_object() -> ibf_table_find_or_insert() -> st_insert()` code path.

	To insert write barrier correctly, we need to store the T_STRUCT VALUE
	inside `struct ibf_dump`. Instead of doing that, let's just demote it
	to WB unproected for correctness. These dumper object are ephemeral so
	there is not a huge benefit for having them WB protected.

	Users of the bootsnap gem ran into crashes due to this issue:
	https://github.com/Shopify/bootsnap/issues/436

	Fixes [Bug #19419]
	---
	 compile.c | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
2023-03-07 10:11:43 +09:00
NARUSE, Yui
f93c7b9f58 merge revision(s) b78f871d838c168789648738e5c67b071beb8a19,ecd0cdaf820af789f355f1a18c31d6adfe8aad94: [Backport #19400]
YJIT: Use the system page size when the code page size is too small
	 (#7267)

	Previously on ARM64 Linux systems that use 64 KiB pages
	(`CONFIG_ARM64_64K_PAGES=y`), YJIT was panicking on boot due to a failed
	assertion.

	The assertion was making sure that code GC can free the last code page
	that YJIT manages without freeing unrelated memory. YJIT prefers picking
	16 KiB as the granularity at which to free code memory, but when the
	system can only free at 64 KiB granularity, that is not possible.

	The fix is to use the system page size as the code page size when the
	system page size is 64 KiB. Continue to use 16 KiB as the code page size
	on common systems that use 16/4 KiB pages.

	Add asserts to code_gc() and free_page() about code GC's assumptions.

	Fixes [Bug #19400]
	---
	 yjit/src/asm/mod.rs    | 78 ++++++++++++++++++++++++++++++++------------------
	 yjit/src/codegen.rs    |  2 --
	 yjit/src/virtualmem.rs | 13 +++++++++
	 3 files changed, 63 insertions(+), 30 deletions(-)

	YJIT: Fix assertion for partially mapped last pages (#7337)

	Follows up [Bug #19400]
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/asm/mod.rs    |  2 +-
	 yjit/src/virtualmem.rs | 18 +++++++++++++-----
	 3 files changed, 33 insertions(+), 6 deletions(-)
2023-03-04 15:39:47 +09:00
NARUSE, Yui
53f6173cfc merge revision(s) 8ce2fb9bbbaea14737c84385b1573f743a30f773,3a0f6ce1d31eefd8af01b50f3632a64d64e8f8c1: [Backport #19415]
Only emit circular dependency warning for owned thread shields [Bug
	 #19415]

	If multiple threads attemps to load the same file concurrently
	it's not a circular dependency issue.

	So we check that the existing ThreadShield is owner by the current
	fiber before warning about circular dependencies.
	---
	 internal/thread.h                                     |  1 +
	 load.c                                                |  3 ++-
	 spec/ruby/core/kernel/shared/require.rb               | 11 +++++++++++
	 spec/ruby/fixtures/code/concurrent_require_fixture.rb |  4 ++++
	 test/ruby/test_require.rb                             |  3 ---
	 thread.c                                              | 11 +++++++++++
	 6 files changed, 29 insertions(+), 4 deletions(-)
	 create mode 100644 spec/ruby/fixtures/code/concurrent_require_fixture.rb

	Use Thread.pass until thread.stop? to wait for thread to block

	[Bug #19415]

	It should be more reliable
	---
	 spec/ruby/fixtures/code/concurrent_require_fixture.rb | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
2023-03-02 09:29:38 +09:00
NARUSE, Yui
31819e82c8 v3.2.1 2023-02-08 13:02:20 +09:00
NARUSE, Yui
3decf7df6f merge revision(s) 3a7367ccc3: [Backport #19403]
mkconfig: Map `includedir` only for system ruby

	Only when installing to the system path on macOS, prepend '$(SDKROOT)'
	and remap `includedir`.
	Fix https://github.com/rbenv/ruby-build/discussions/2123
	---
	 test/mkmf/test_config.rb | 4 ++--
	 test/test_rbconfig.rb    | 9 ---------
	 tool/mkconfig.rb         | 4 +++-
	 3 files changed, 5 insertions(+), 12 deletions(-)
2023-02-07 15:15:17 +09:00
NARUSE, Yui
7246cd0081 merge revision(s) fad48fefe1: [Backport #19399]
[Bug #19399] Parsing invalid heredoc inside block parameter

	Although this is of course invalid as Ruby code, allow to just parse
	and tokenize.
	---
	 ext/ripper/lib/ripper/lexer.rb |  2 +-
	 test/ripper/test_lexer.rb      | 12 ++++++++++++
	 2 files changed, 13 insertions(+), 1 deletion(-)
2023-02-07 13:46:36 +09:00
NARUSE, Yui
3426ebd048 merge revision(s) c6f84e9189: [Backport #19398]
[Bug #19398] Memory leak in WeakMap

	There's a memory leak in ObjectSpace::WeakMap due to not freeing
	the `struct weakmap`. It can be seen in the following script:

	```
	100.times do
	  10000.times do
	    ObjectSpace::WeakMap.new
	  end

	  # Output the Resident Set Size (memory usage, in KB) of the current Ruby process
	  puts `ps -o rss= -p #{$$}`
	end
	```
	---
	 gc.c                      | 1 +
	 test/ruby/test_weakmap.rb | 9 +++++++++
	 2 files changed, 10 insertions(+)
2023-02-06 16:41:23 +09:00
NARUSE, Yui
3a88589399 merge revision(s) 3b83b265f1: [Backport #19404]
YJIT: Crash with rb_bug() when panicking

	Helps with getting good bug reports in the wild. Intended to be
	backported to the 3.2.x series.
	---
	 yjit/bindgen/src/main.rs       |  3 +++
	 yjit/src/cruby_bindings.inc.rs |  1 +
	 yjit/src/yjit.rs               | 29 +++++++++++++++++++++++++++--
	 3 files changed, 31 insertions(+), 2 deletions(-)
2023-02-06 14:00:47 +09:00
NARUSE, Yui
535d863f34 merge revision(s) 188688a53e: [Backport #19385]
[PATCH 1/4] YJIT: Move CodegenGlobals::freed_pages into an Rc

	This allows for supplying a freed_pages vec in Rust tests. We need it so we
	can test scenarios that occur after code GC.
	---
	 yjit/src/asm/mod.rs | 48 +++++++++++++++++++++++++++++++++------------
	 yjit/src/codegen.rs | 16 ++++-----------
	 2 files changed, 39 insertions(+), 25 deletions(-)

	Subject: [PATCH 2/4] YJIT: other_cb is None in tests

	Since the other cb is in CodegenGlobals, and we want Rust tests to be
	self-contained.
	---
	 yjit/src/asm/mod.rs | 1 +
	 1 file changed, 1 insertion(+)

	Subject: [PATCH 3/4] YJIT: ARM64: Move functions out of arm64_emit()

	---
	 yjit/src/backend/arm64/mod.rs | 180 +++++++++++++++++-----------------
	 1 file changed, 90 insertions(+), 90 deletions(-)

	Subject: [PATCH 4/4] YJIT: ARM64: Fix long jumps to labels

	Previously, with Code GC, YJIT panicked while trying to emit a B.cond
	instruction with an offset that is not encodable in 19 bits. This only
	happens when the code in an assembler instance straddles two pages.

	To fix this, when we detect that a jump to a label can land on a
	different page, we switch to a fresh new page and regenerate all the
	code in the assembler there. We still assume that no one assembler has
	so much code that it wouldn't fit inside a fresh new page.

	[Bug #19385]
	---
	 yjit/src/backend/arm64/mod.rs | 65 ++++++++++++++++++++++++++++++++---
	 1 file changed, 60 insertions(+), 5 deletions(-)
2023-02-03 14:13:09 +09:00
NARUSE, Yui
40e0b1e123 merge revision(s) 9726736006: [Backport #19327]
Set STR_SHARED_ROOT flag on root of string

	---
	 string.c | 1 +
	 1 file changed, 1 insertion(+)
2023-01-31 23:46:50 +09:00
NARUSE, Yui
ca75332f46 merge revision(s) eccfc978fd: [Backport #19379]
Fix parsing of regexps that toggle extended mode on/off inside regexp

	This was broken in ec3542229b. That commit
	didn't handle cases where extended mode was turned on/off inside the
	regexp.  There are two ways to turn extended mode on/off:

	```
	/(?-x:#y)#z
	/x =~ '#y'

	/(?-x)#y(?x)#z
	/x =~ '#y'
	```

	These can be nested inside the same regexp:

	```
	/(?-x:(?x)#x
	(?-x)#y)#z
	/x =~ '#y'
	```

	As you can probably imagine, this makes handling these regexps
	somewhat complex. Due to the nesting inside portions of regexps,
	the unassign_nonascii function needs to be recursive.  In
	recursive mode, it needs to track both opening and closing
	parentheses, similar to how it already tracked opening and
	closing brackets for character classes.

	When scanning the regexp and coming to `(?` not followed by `#`,
	scan for options, and use `x` and `i` to determine whether to
	turn on or off extended mode.  For `:`, indicting only the
	current regexp section should have the extended mode
	switched, recurse with the extended mode set or unset. For `)`,
	indicating the remainder of the regexp (or current regexp portion
	if already recursing) should turn extended mode on or off, just
	change the extended mode flag and keep scanning.

	While testing this, I noticed that `a`, `d`, and `u` are accepted
	as options, in addition to `i`, `m`, and `x`, but I can't see
	where those options are documented.  I'm not sure whether or not
	handling  `a`, `d`, and `u` as options is a bug.

	Fixes [Bug #19379]
	---
	 re.c                     | 153 +++++++++++++++++++++++++++++++++++++----------
	 test/ruby/test_regexp.rb |  56 +++++++++++++++++
	 2 files changed, 176 insertions(+), 33 deletions(-)
2023-01-31 15:28:01 +09:00
NARUSE, Yui
5a2b28909e merge revision(s) 3f54d09a5b: [Backport #19390]
bignum.c: rb_int_parse_cstr handle `0` strings

	[Bug #19390]

	We shouldn't check the string length when skipping zeros, as the
	string might only contains zero characters, resulting in an empty string.
	---
	 bignum.c               | 1 -
	 test/ruby/test_time.rb | 4 ++++
	 2 files changed, 4 insertions(+), 1 deletion(-)
2023-01-31 13:39:13 +09:00
NARUSE, Yui
1689d8bb48 merge revision(s) 21dced8b01: [Backport #19389]
[ruby/stringio] [Bug #19389] Fix chomping with longer separator

	eb322a9716
	---
	 ext/stringio/stringio.c        | 5 +++--
	 test/stringio/test_stringio.rb | 2 ++
	 2 files changed, 5 insertions(+), 2 deletions(-)
2023-01-31 11:08:50 +09:00