summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-07-25merge revision(s) fac814c2dc31afef272b45392a7389ef0bfa3a4f: [Backport #19602]U.Nakamura
Fix `PLATFORM_GET_INC` On platforms where unaligned word access is not allowed, and if `sizeof(val)` and `sizeof(type)` differ: - `val` > `type`, `val` will be a garbage. - `val` < `type`, outside `val` will be clobbered. --- regexec.c | 2 +- regint.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) note: ruby_3_1 is patched regint.h only
2023-07-25merge revision(s) bd786e78969f9d4a8699376ceafe10934b6ad533: [Backport #19084]U.Nakamura
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-25merge revision(s) 09295ea796900fb7b05d29e93364090e21598566: [Backport #19543]U.Nakamura
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-25Backport cvar clone bug fix for 19379 to 3.1 (#7889)Eileen M. Uchitelle
* Copy cvar table on clone When a class with a class variable is cloned we need to also copy the cvar cache table from the original table to the clone. I found this bug while working on fixing [Bug #19379]. While this does not fix that bug directly it is still a required change to fix another bug revealed by the fix in https://github.com/ruby/ruby/pull/7265 This needs to be backported to 3.2.x and 3.1.x. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> * Fix cvar caching when class is cloned The class variable cache that was added in https://github.com/ruby/ruby/pull/4544 changed the behavior of class variables on cloned classes. As reported when a class is cloned AND a class variable was set, and the class variable was read from the original class, reading a class variable from the cloned class would return the value from the original class. This was happening because the IC (inline cache) is stored on the ISEQ which is shared between the original and cloned class, therefore they share the cache too. To fix this we are now storing the `cref` in the cache so that we can check if it's equal to the current `cref`. If it's different we don't want to read from the cache. If it's the same we do. Cloned classes don't share the same cref with their original class. This will need to be backported to 3.1 in addition to 3.2 since the bug exists in both versions. We also added a marking function which was missing. Fixes [Bug #19379] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> * Add missing write barrier We were missing the write barrier for class_value to cref. This should fix the segv we were seeing in http://ci.rvm.jp/logfiles/brlog.trunk-gc-asserts.20230601-165052 Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> --------- Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2023-07-25String#slice! should clear the coderange when truncatingU.Nakamura
[Bug #19739] This bug was incidentally fixed in Ruby 3.2 via b0b9f72 but remains on 3.1 and older. this patch is written by byroot, https://github.com/Shopify/ruby/commit/3b351ee62d4206bb72301c2e98dcb173f1e35be7 Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2023-07-18merge revision(s) 537183cd2ac0163851277b46a2f21ea5914c11c0: [Backport #19577]U.Nakamura
Fix write barrier order for `klass` to `cme` edge Previously, the following crashes with `CFLAGS=-DRGENGC_CHECK_MODE=2 -DRUBY_DEBUG=1 -fno-inline`: $ ./miniruby -e 'GC.stress = true; Marshal.dump({})' It crashes with a write barrier (WB) miss assertion on an edge from the `Hash` class object to a newly allocated negative method entry. This is due to usages of vm_ccs_create() running the WB too early, before the method entry is inserted into the cc table, so before the reference edge is established. The insertion can trigger GC and promote the class object, so running the WB after the insertion is necessary. Move the insertion into vm_ccs_create() and run the WB after the insertion. Discovered on CI: http://ci.rvm.jp/results/trunk-asserts@ruby-sp2-docker/4391770 --- vm_eval.c | 3 +-- vm_insnhelper.c | 10 ++++++---- vm_method.c | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-)
2023-07-18merge revision(s) 52e571fa72debcd764765775bd1b76ee87e36d2d: [Backport #19580]U.Nakamura
Ensure ruby_xfree won't segfault if called after vm_destruct [Bug #19580] The real-world scenario motivating this change is libxml2's pthread code which uses `pthread_key_create` to set up a destructor that is called at thread exit to free thread-local storage. There is a small window of time -- after ruby_vm_destruct but before the process exits -- in which a pthread may exit and the destructor is called, leading to a segfault. Please note that this window of time may be relatively large if `atexit` is being used. --- gc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
2023-07-18merge revision(s) 02a7e12b80823919fb614ad3ea6241d5115d14fe: [Backport #19593]U.Nakamura
Ensure throw data is not set as cause [Bug #19593] rb_ec_setup_exception did not check if errinfo is a throw_data. This can cause crashes in code since it is assumed that id_cause is an object. We saw a crash in show_cause due to id_cause of errinfo being a throw_data. It crashes on rb_obj_is_kind_of since it cannot be called on T_IMEMO objects. Unfortunately, we couldn't find a reproduction script, however we debugged the core dump and rb_ec_setup_exception is the only place where id_cause is assigned from errinfo without checking if it is a throw_data. ``` 0x0000556c5708e6dd in sigsegv (sig=11, info=0x7f301befa3f0, ctx=0x7f301befa2c0) at signal.c:964 0x00007f301d046420 in <signal handler called> () at /lib/x86_64-linux-gnu/libpthread.so.0 class_search_class_ancestor (c=139844586301760, cl=<optimized out>) at object.c:810 rb_obj_is_kind_of (obj=obj@entry=139839221734880, c=139844586301760) at object.c:861 0x0000556c56f2f00f in show_cause (errinfo=errinfo@entry=139838840645160, str=str@entry=139839221730520, opt=139839221730480, highlight=0, reverse=reverse@entry=0, backtrace_limit=backtrace_limit@entry=-1, shown_causes=0x7ffe9d1a2d68) at ./include/ruby/internal/special_consts.h:175 ``` Co-Authored-By: Jean Boussier <byroot@ruby-lang.org> --- eval.c | 4 ++++ 1 file changed, 4 insertions(+)
2023-06-29* 2023-06-29 [ci skip]git
2023-06-29CVE-2023-36617 for Ruby 3.1 (#7996)Hiroshi SHIBATA
* Bump up v0.12.2 * Merge URI-0.10.3 for Bundler
2023-06-26merge revision(s) 038f9ade3c4d965415e4956561975454cf9eeb21: [Backport #19585]U.Nakamura
Use tools appropriate with CC To get rid of mysterious errors such as: ``` /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: error: libruby.3.3-static.a(/): The end of the file was unexpectedly encountered ``` and ``` ld: warning: ignoring file ../../libruby.3.3-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64 Undefined symbols for architecture x86_64: "_rb_rational_num", referenced from: ``` --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+)
2023-06-26merge revision(s) 2c8f287: [Backport #19532]U.Nakamura
Fix handling of 6-byte codepoints in left_adjust_char_head in CESU-8 encoding --- enc/cesu_8.c | 23 +++++++++++++++++++---- test/ruby/enc/test_cesu8.rb | 4 ++++ 2 files changed, 23 insertions(+), 4 deletions(-)
2023-06-20more fixU.Nakamura
2023-06-20Fix previous commitU.Nakamura
2023-06-19merge revision(s) d2520b7b76759118071a16e6bca22726a5de9fb4: [Backport #19439]U.Nakamura
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-06-19merge revision(s) 1cdf8ab07b24ebd16e93621957196e8b1d67f2ba: [Backport #19323]U.Nakamura
[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-15* 2023-06-15 [ci skip]git
2023-06-15Fix test-bundled-gems for Ruby 3.1 (#7935)Hiroshi SHIBATA
* pry is not needed for test-bundled-gems * Run test-unit test without rake task to avoid yard dependency * Try to skip Prime_test.rb
2023-05-08* 2023-05-08 [ci skip]git
2023-05-08Skip drb tests on mswin (#7789)NARUSE, Yui
* Skip TestDRbSSLAry on mswin This doesn't seem to stably work on mswin: https://github.com/ruby/ruby/actions/runs/3505363753/jobs/5871633211 For CI stability, it generally seems like a bad idea to run druby tests on Windows, given that it's pretty much unstable on MinGW as well. * Do not run drb SSL tests on Windows These tests often cause a timeout and this issue seems specific to the Windows platforms. https://github.com/ruby/ruby/actions/runs/3603761925/jobs/6072346738 --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-05-05* 2023-05-05 [ci skip]git
2023-05-05Use vcpkg instead of chocolatey for openssl (#7788)NARUSE, Yui
2023-03-30Merge Time-0.2.2v3_1_4Hiroshi SHIBATA
2023-03-30bump patchlevelnagachika
2023-03-29* 2023-03-29 [ci skip]git
2023-03-29Added assert_linear_performance for URI testsHiroshi SHIBATA
2023-03-29Merge URI-0.10.2 for bundlerHiroshi SHIBATA
2023-03-29Merge URI-0.12.1Hiroshi SHIBATA
2023-03-27merge revision(s) ↵nagachika
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-26Merge URI-0.12.0Hiroshi SHIBATA
2023-03-26merge revision(s) e7342e76dfd26237c604e42f9a59a1eaa578c94e: [Backport #19485]nagachika
[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-25merge revision(s) 195e32977f181c8af9233a12cfc2c98e0f7957f6:nagachika
Skip test_udp_server on s390x RHEL 7.1 It seems like it never succeeds on this CI. --- test/socket/test_socket.rb | 4 ++++ 1 file changed, 4 insertions(+)
2023-03-25merge revision(s) 8d1109c03bacc952b6218af2e4ae9b74c9855273:nagachika
Added assertion values for Amazon Linux 2023 --- spec/ruby/core/file/utime_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
2023-03-25merge revision(s) ↵nagachika
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-03-25merge revision(s) 7bd7aee02e303de27d2cddfc5ef47e612d6782cb: [Backport #18464]nagachika
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-03-25merge revision(s) 790cf4b6d0475614afb127b416e87cfa39044d67: [Backport #19115]nagachika
Fix autoload status of statically linked extensions Previously, for statically-linked extensions, we used `vm->loading_table` to delay calling the init function until the extensions are required. This caused the extensions to look like they are in the middle of being loaded even before they're required. (`rb_feature_p()` returned true with a loading path output.) Combined with autoload, queries like `defined?(CONST)` and `Module#autoload?` were confused by this and returned nil incorrectly. RubyGems uses `defined?` to detect if OpenSSL is available and failed when OpenSSL was available in builds using `--with-static-linked-ext`. Use a dedicated table for the init functions instead of adding them to the loading table. This lets us remove some logic from non-EXTSTATIC builds. [Bug #19115] --- load.c | 55 +++++++++++++++++++++++++++++++++++----------- test/ruby/test_autoload.rb | 18 +++++++++++++++ vm.c | 3 +++ vm_core.h | 9 ++++++++ 4 files changed, 72 insertions(+), 13 deletions(-)
2023-03-25fixup for 823835499539aa53128a025ab72eb00c288dfb09.nagachika
2023-03-25merge revision(s) d6ce4180a5b4dacbac895c9911031a6df6c61136: [Backport #19243]nagachika
Windows: Fix encoding of Dir.home Dir.home returns an UTF-8 string since ruby-3.0, but the actual encoding of the bytes was CP_ACP or CP_OEMCP. That led to invalid bytes when calling Dir.home with an unicode username. --- spec/ruby/core/dir/home_spec.rb | 11 +++++++++++ win32/file.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)
2023-03-25merge revision(s) 2e7e153a2af1456515d43b6381e38534b069b1c2: [Backport #19242]nagachika
[Bug #19242] Prohibit circular causes to be loaded --- error.c | 4 ++++ eval.c | 4 ++++ eval_error.c | 11 +++++++++++ test/ruby/test_exception.rb | 12 ++++++++++++ 4 files changed, 31 insertions(+)
2023-03-25merge revision(s) cd5cafa4a380e2459862b6e99ff0c381362ef1be: [Backport #18827]nagachika
Respect the encoding of the source [Bug #18827] Do not override the input string encoding at the time of preparation, the source encoding is not determined from the input yet. --- parse.y | 26 ++++++++++++++++---------- test/ruby/test_ast.rb | 13 +++++++++++++ test/ruby/test_syntax.rb | 9 +++++++++ 3 files changed, 38 insertions(+), 10 deletions(-)
2023-03-25merge revision(s) c5475f42694eff35465c3332e0182c0611ca5918: [Backport #18748]nagachika
Fix Range#cover? returning true for beginless ranges of different types Previously `(2..).cover?("2"..)` was false, but `(..2).cover?(.."2")` was true. This changes it so both are false, treating beginless ranges the same as endless ranges in regards to type checks. This also adds documentation to #cover? to describe behavior with beginless and endless ranges, testing each documentation example, which is how this bug was found. Fixes [Bug #18155] --- range.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- test/ruby/test_range.rb | 29 ++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-)
2023-03-25merge revision(s) f229b36087f1b387d77af8f3fa50f9bffd2fd44e: [Backport #18989]nagachika
Fix test fail with assert_ractor outside of ruby/ruby repo Revert 806583c093ecc2d67830f0a8f0d94decf0ed71e5 --- tool/lib/core_assertions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
2023-03-25Revert "Skip the test for [Bug #19316] for a while."nagachika
This reverts commit 82d763c94ad693a2af8086df8e0455b7de2d2ce3, and add exit: :any to assert_compile. Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2023-03-21merge revision(s) 96d1acfdf6c6b42f2029f44d5b5920961d6efa92: [Backport #19161]nagachika
[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-21merge revision(s) dd28c55a7cd6780dad637b4d6a20507fbfc6af4a: [Backport #19445]nagachika
[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-21merge revision(s) 86de48e9f69b665ba9ffb5bdc5a181a3adb1a7b8: [Backport #19419]nagachika
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-21merge revision(s) ↵nagachika
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-21merge revision(s) 3a7367ccc319499127ead147e5a08f769e44208e: [Backport #19403]nagachika
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-03-21merge revision(s) c6f84e918943a0bf8db6fee556fc53180d257510: [Backport #19398]nagachika
[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-03-21Skip the test for [Bug #19316] for a while.nagachika