Граф коммитов

82481 Коммитов

Автор SHA1 Сообщение Дата
John Hawthorn dfd29cab1f
Avoid unnecessary writes to ISEQ during GC
On mark we check whether a callcache has been invalidated and if it has
we replace it with the empty callcache, rb_vm_empty_cc(). However we
also consider the empty callcache to not be active, and so previously
would overwrite it with itself.

These additional writes are problematic because they may force
Copy-on-Write to occur on the memory page, increasing system memory use.
2024-11-14 09:43:17 -05:00
John Hawthorn dedf5b0480
Avoid unnecessary writes to imemo_env during GC
Similar to the previous commit, to avoid unnecessary Copy-on-Write
memory use we should only set this flag when it has not previously been
set.
2024-11-14 09:43:16 -05:00
John Hawthorn f4258aaed0
[Bug #20886] Avoid double-free in regex timeout after stack_double (#12063)
Fix regex timeout double-free after stack_double

As of 10574857ce, it's possible to crash
on a double free due to `stk_alloc` AKA `msa->stack_p` being freed
twice, once at the end of match_at and a second time in `FREE_MATCH_ARG`
in the parent caller.

Fixes [Bug #20886]
2024-11-12 09:04:21 -08:00
John Hawthorn a51a6bf692
[Bug #20883] Fix coderange for sprintf on binary strings (#12040)
Fix update_coderange for binary strings

Although a binary (aka ASCII-8BIT) string will never have a broken
coderange, it still has to differentiate between "valid" and "7bit".

On Ruby 3.4/trunk this problem is masked because we now clear the
coderange more agressively in rb_str_resize, and we happened to always
be strinking this string, but we should not assume that.

On Ruby 3.3 this created strings where `ascii_only?` was true in cases
it shouldn't be as well as other problems.

Fixes [Bug #20883]

Co-authored-by: Daniel Colson <danieljamescolson@gmail.com>
Co-authored-by: Matthew Draper <matthew@trebex.net>
2024-11-09 01:00:13 -08:00
Takashi Kokubun 75015d4c1f v3.3.6 2024-11-04 16:49:11 -08:00
Takashi Kokubun f72eb702f2 Skip tests that suddenly started failing for MinGW
These test failures first appeared on irrelevant changes. It probably
came from changes in GitHub Actions instead of CRuby's.

Until we figure out how to fix these tests, let's skip them to make the
CI usable.
2024-11-04 16:00:11 -08:00
Takashi Kokubun 7237ded95f macos-12 is deprecated and fails on Mondays
https://github.com/actions/runner-images/issues/10721
2024-11-04 14:52:43 -08:00
Takashi Kokubun 6db39f4677 merge revision(s) 29c480dd6fca993590c82078ba797e2c4e876ac7: [Backport #20853]
[Bug #20853] Fix Proc#hash to not change after compaction

	The hash value of a Proc must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.
2024-11-04 14:43:39 -08:00
Takashi Kokubun edeb0319f7 merge revision(s) 6118e8a47394409b53164b60e79fadf348b97db3: [Backport #20716]
Fix method caching bug when including/prepend module A that prepends module B

	Fix by always adding the generated iclass to the subclasses list,
	otherwise the method cache for the iclass is not cleared when
	the method in the module is overwritten.

	Fixes [Bug #20716]
2024-11-04 14:42:47 -08:00
Takashi Kokubun 5ce0ba0d41 merge revision(s) 35e124832e29b65c84d4e0e4e434616859f9bdf5: [Backport #20755]
[Bug #20755] Frozen string should not be writable via IO::Buffer
2024-11-04 14:39:22 -08:00
Takashi Kokubun 12ea98e8c8 merge revision(s) 637067440f74043c6d79fc649ab8acf1afea25a5: [Backport #20752]
[Bug #20752] Slice of readonly `IO::Buffer` also should be readonly
2024-11-04 14:38:18 -08:00
Takashi Kokubun 34a0f41d0a merge revision(s) c1862cbb89a6bf42dcd07d92fe4f4bfeebca5775: [Backport #20719]
[Bug #20719] `Float` argument must be ASCII compatible
2024-11-04 14:37:14 -08:00
Takashi Kokubun 2b713dcb89 merge revision(s) d33e3d47b84a73b38644f2a3d41881ce9be6ef18: [Backport #20704]
[Bug #20704] Win32: Fix chdir to non-ASCII path

	On Windows, `chdir` in compilers' runtime libraries uses the active
	code page, but command line arguments in ruby are always UTF-8, since
	commit:33ea2646b98adb49ae2e1781753bf22d33729ac0.
2024-11-04 14:36:36 -08:00
Takashi Kokubun e7c939aea1 merge revision(s) 76ea5cde2a0f4834a5228104249b6b3346ddfc94: [Backport #20777]
Refactor RUBY_DESCRIPTION assertions in test_rubyoptions
2024-11-04 14:29:25 -08:00
Jonathan Calvert 7446f7cdd1 merge revision(s) 0d16c36d0ab2afa2ec79b72b229e69c141ebdaba: [Backport #13831]
[win32/registry] Fallback to UTF-8 for unknown codepages

	There are some codepages like cp708 for which no ruby encoding exists:

	    $ ruby -e "Encoding.find('cp708')"
	    Traceback (most recent call last):
	    	1: from -e:1:in `<main>'
	    -e:1:in `find': unknown encoding name - cp708 (ArgumentError)

	win32/registry uses ENCODING to transcode error messages and expand environment
	variables from UTF-16LE, so using UTF-8 seems like the best choice and is better
	than a hard failure.

	This should resolve [Bug #13831]
2024-11-04 14:26:25 -08:00
Alex Myers 6b3a0b4ffd
Bump REXML to 3.3.9 for Ruby 3.3 (#11972) 2024-11-01 08:42:18 -07:00
Hiroshi SHIBATA c4b6ce3675 Merge syntax-suggest-2.0.1 2024-10-21 08:41:50 -07:00
Hiroshi SHIBATA 494fcc507b Merge RubyGems-3.5.22 and Bundler-2.5.22 2024-10-17 08:55:01 -07:00
Hiroshi SHIBATA d03e4228aa Merge RubyGems-3.5.21 and Bundler-2.5.21 2024-10-17 08:55:01 -07:00
Nobuyoshi Nakada af7656869e Run just bignum related tests when gmp enabled 2024-09-30 09:16:44 -07:00
Hiroshi SHIBATA 4608ef8d7b -l option of 7z is unknown switch with the `ubuntu-latest`.
https://github.com/ruby/actions/actions/runs/11095032727/job/30823174026#step:3:349
2024-09-30 09:16:44 -07:00
Hiroshi SHIBATA 77fb1bf434 Merge RubyGems-3.5.20 and Bundler-2.5.20 2024-09-25 10:56:17 -07:00
Hiroshi SHIBATA 3894841182 Merge RubyGems-3.5.19 and Bundler-2.5.19 2024-09-25 10:56:17 -07:00
Hiroshi SHIBATA ef3c4a7aa7 Merge RubyGems-3.5.18 and Bundler-2.5.18 2024-09-25 10:56:17 -07:00
Hiroshi SHIBATA 95f72a4a32 Merge RubyGems-3.5.17 and Bundler-2.5.17 2024-09-25 10:56:17 -07:00
Nobuyoshi Nakada d8966416d0
Use `PRIuSIZE` instead of `%zu` for `size_t` (#9359)
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2024-09-24 10:50:33 -07:00
Takashi Kokubun ec04de7512 Bump debug.gem to 1.9.2 2024-09-23 09:25:10 -07:00
KJ Tsanaktsidis 5b6009870d Ensure fiber scheduler is woken up when close interrupts read
If one thread is reading and another closes that socket, the close
blocks waiting for the read to abort cleanly. This ensures that Ruby is
totally done with the file descriptor _BEFORE_ we tell the OS to close
and potentially re-use it.

When the read is correctly terminated, the close should be unblocked.
That currently works if closing is happening on a thread, but if it's
happening on a fiber with a fiber scheduler, it does NOT work.

This patch ensures that if the close happened in a fiber scheduled
thread, that the scheduler is notified that the fiber is unblocked.

[Bug #20723]
2024-09-23 09:25:10 -07:00
Hiroshi SHIBATA 4e59e7d35f
[Bug #20737] Do not warn default gems to be promoted in Ruby 3.5 (#11613) 2024-09-16 17:28:08 -07:00
Jonathan Calvert 55ddfd58dd
Fixes [Bug #20718] (#11576)
Fixes [Bug #20718]

Allow objects that are not of type `RTypedData` to use the default free function, as `RTYPEDDATA_EMBEDDED_P` can return a false positive when casting non-`RTypedData` objects
2024-09-10 17:38:48 -07:00
Takashi Kokubun 948ca04a76 Allow failures for all Travis jobs
Every job on Travis is unstable now.
2024-09-05 18:00:19 -07:00
Hiroshi SHIBATA c3f7041ab1
Merge reline-0.5.10 (#11558)
* Merge reline-0.5.8

* Merge reline-0.5.9

* Merge reline-0.5.10
2024-09-05 17:55:34 -07:00
Hiroshi SHIBATA 4eb51dfc9e
Merge JSON 2.7.2 for Ruby 3.3 (#11541)
Merge JSON 2.7.2
2024-09-04 08:47:06 -07:00
Takashi Kokubun ef084cc8f4 v3.3.5 2024-09-02 09:09:08 -07:00
Takashi Kokubun d3ab7be8ca merge revision(s) 657f4b99f61: [Backport #20667]
Update bundled gems list as of 2024-08-02
2024-09-02 03:28:11 -07:00
Takashi Kokubun c69d59e9b2 Sync tool/lib/core_assertions.rb from master
It seems necessary to pass test-bundled-gems with REXML.
2024-09-02 03:25:23 -07:00
Takashi Kokubun cf9a6c2b63 merge revision(s) a3562c2a0abf1c2bdd1d50377b4f929580782594: [Backport #20701]
Remove incorrect setting of KW_SPLAT_MUT flag

	Fixes [Bug #20701]

	Co-authored-by: Pablo Herrero <pablodherrero@gmail.com>
2024-09-02 03:19:13 -07:00
Takashi Kokubun d83b5633b1 merge revision(s) 992596fb7af18a7f472589a607d0eb3fbb03b49a: [Backport #20344]
Fix next inside block argument stack underflow

	[Bug #20344]
	Fix compile_next adding removable adjust label
2024-09-02 03:10:19 -07:00
Takashi Kokubun b210c86a02 merge revision(s) 97449338d6cb42d9dd7c9ca61550616e7e6b6ef6: [Backport #20649]
[Bug #20649] Allow `nil` as 2nd argument of `assign_error`

	Fallback to the last token element in that case, for the backward
	compatibilities.
2024-09-02 03:07:09 -07:00
Takashi Kokubun 6a4e79533b merge revision(s) 1870505f478cc75993b296b7144a45137ace6937: [Backport #20651]
Fix wrong unreachable chunk remove when jump destination label is unremovable
2024-09-02 02:56:18 -07:00
Takashi Kokubun e0e23e7d5e merge revision(s) 29500e30346: [Backport #20667]
Update bundled gems list as of 2024-08-22
2024-09-02 02:52:51 -07:00
Takashi Kokubun 7b954e7bc6 Allow failures in Travis ppc64le and s390x
Those jobs are way too unstable and provide very little benefit.

e.g.
https://app.travis-ci.com/github/ruby/ruby/jobs/624611955
https://app.travis-ci.com/github/ruby/ruby/jobs/625551620
2024-09-02 02:44:25 -07:00
Hiroshi SHIBATA 937964f346
Merge URI-0.13.1 for Ruby 3.3 (#11466)
Merge URI-0.13.1
2024-08-27 16:00:27 -07:00
Peter Zhu ac8d50e52e
[Backport 3.3] [Bug #20691] Fix use-after-free in WeakKeyMap#clear (#11443)
Fix use-after-free in WeakKeyMap#clear

[Bug #20691]

If the WeakKeyMap has been marked but sweeping hasn't started yet and we
cann WeakKeyMap#clear, then there could be a use-after-free because we do
not call rb_gc_remove_weak to remove the key from the GC.

For example, the following code triggers use-after-free errors in Valgrind:

    map = ObjectSpace::WeakKeyMap.new

    1_000.times do
      1_000.times do
        map[Object.new] = nil
      end

      map.clear
    end

Output from Valgrind:

    ==61230== Invalid read of size 8
    ==61230==    at 0x25CAF8: gc_update_weak_references (default.c:5593)
    ==61230==    by 0x25CAF8: gc_marks_finish (default.c:5641)
    ==61230==    by 0x26031C: gc_marks_continue (default.c:5987)
    ==61230==    by 0x26031C: gc_continue (default.c:2255)
    ==61230==    by 0x2605FC: newobj_cache_miss (default.c:2589)
    ==61230==    by 0x26111F: newobj_alloc (default.c:2622)
    ==61230==    by 0x26111F: rb_gc_impl_new_obj (default.c:2701)
    ==61230==    by 0x26111F: newobj_of (gc.c:890)
    ==61230==    by 0x26111F: rb_wb_protected_newobj_of (gc.c:917)
    ==61230==    by 0x2DE218: rb_class_allocate_instance (object.c:131)
    ==61230==    by 0x2E32A8: class_call_alloc_func (object.c:2141)
    ==61230==    by 0x2E32A8: rb_class_alloc (object.c:2113)
    ==61230==    by 0x2E32A8: rb_class_new_instance_pass_kw (object.c:2172)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)
    ==61230==  Address 0x2159cb00 is 0 bytes inside a block of size 8 free'd
    ==61230==    at 0x4849B2C: free (vg_replace_malloc.c:989)
    ==61230==    by 0x248EF1: rb_gc_impl_free (default.c:8512)
    ==61230==    by 0x248EF1: rb_gc_impl_free (default.c:8493)
    ==61230==    by 0x248EF1: ruby_sized_xfree.constprop.0 (gc.c:4178)
    ==61230==    by 0x4627EC: wkmap_free_table_i (weakmap.c:652)
    ==61230==    by 0x3A54AF: apply_functor (st.c:1633)
    ==61230==    by 0x3A54AF: st_general_foreach (st.c:1543)
    ==61230==    by 0x3A54AF: rb_st_foreach (st.c:1640)
    ==61230==    by 0x46203C: wkmap_clear (weakmap.c:973)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)
    ==61230==  Block was alloc'd at
    ==61230==    at 0x484680F: malloc (vg_replace_malloc.c:446)
    ==61230==    by 0x25C68E: rb_gc_impl_malloc (default.c:8527)
    ==61230==    by 0x4622E9: wkmap_aset_replace (weakmap.c:817)
    ==61230==    by 0x3A4D02: rb_st_update (st.c:1487)
    ==61230==    by 0x4623E4: wkmap_aset (weakmap.c:854)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)
    ==61230==
    ==61230== Invalid write of size 8
    ==61230==    at 0x25CB3B: gc_update_weak_references (default.c:5598)
    ==61230==    by 0x25CB3B: gc_marks_finish (default.c:5641)
    ==61230==    by 0x26031C: gc_marks_continue (default.c:5987)
    ==61230==    by 0x26031C: gc_continue (default.c:2255)
    ==61230==    by 0x2605FC: newobj_cache_miss (default.c:2589)
    ==61230==    by 0x26111F: newobj_alloc (default.c:2622)
    ==61230==    by 0x26111F: rb_gc_impl_new_obj (default.c:2701)
    ==61230==    by 0x26111F: newobj_of (gc.c:890)
    ==61230==    by 0x26111F: rb_wb_protected_newobj_of (gc.c:917)
    ==61230==    by 0x2DE218: rb_class_allocate_instance (object.c:131)
    ==61230==    by 0x2E32A8: class_call_alloc_func (object.c:2141)
    ==61230==    by 0x2E32A8: rb_class_alloc (object.c:2113)
    ==61230==    by 0x2E32A8: rb_class_new_instance_pass_kw (object.c:2172)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)
    ==61230==  Address 0x2159cb00 is 0 bytes inside a block of size 8 free'd
    ==61230==    at 0x4849B2C: free (vg_replace_malloc.c:989)
    ==61230==    by 0x248EF1: rb_gc_impl_free (default.c:8512)
    ==61230==    by 0x248EF1: rb_gc_impl_free (default.c:8493)
    ==61230==    by 0x248EF1: ruby_sized_xfree.constprop.0 (gc.c:4178)
    ==61230==    by 0x4627EC: wkmap_free_table_i (weakmap.c:652)
    ==61230==    by 0x3A54AF: apply_functor (st.c:1633)
    ==61230==    by 0x3A54AF: st_general_foreach (st.c:1543)
    ==61230==    by 0x3A54AF: rb_st_foreach (st.c:1640)
    ==61230==    by 0x46203C: wkmap_clear (weakmap.c:973)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)
    ==61230==  Block was alloc'd at
    ==61230==    at 0x484680F: malloc (vg_replace_malloc.c:446)
    ==61230==    by 0x25C68E: rb_gc_impl_malloc (default.c:8527)
    ==61230==    by 0x4622E9: wkmap_aset_replace (weakmap.c:817)
    ==61230==    by 0x3A4D02: rb_st_update (st.c:1487)
    ==61230==    by 0x4623E4: wkmap_aset (weakmap.c:854)
    ==61230==    by 0x4296BC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3788)
    ==61230==    by 0x44A9CD: vm_sendish (vm_insnhelper.c:5955)
    ==61230==    by 0x44A9CD: vm_exec_core (insns.def:898)
    ==61230==    by 0x43A0E4: rb_vm_exec (vm.c:2564)
    ==61230==    by 0x2341B4: rb_ec_exec_node (eval.c:281)
    ==61230==    by 0x236258: ruby_run_node (eval.c:319)
    ==61230==    by 0x15D665: rb_main (main.c:43)
    ==61230==    by 0x15D665: main (main.c:62)

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-08-23 15:48:08 -07:00
Peter Zhu 8657de70aa
[Backport 3.3] [Bug #20688] Fix use-after-free for WeakMap and WeakKeyMap (#11439)
* Add struct weakmap_entry for WeakMap entries

* Refactor wmap_foreach to pass weakmap_entry

* Use wmap_foreach for wmap_mark

* Refactor wmap_compact to use wmap_foreach

* Remove wmap_free_entry

* Fix WeakMap use-after-free

[Bug #20688]

We cannot free the weakmap_entry before the ST_DELETE because it could
hash the key which would read the weakmap_entry and would cause a
use-after-free. Instead, we store the entry and free it on the next
iteration.

For example, the following script triggers a use-after-free in Valgrind:

    weakmap = ObjectSpace::WeakMap.new
    10_000.times { weakmap[Object.new] = Object.new }

    ==25795== Invalid read of size 8
    ==25795==    at 0x462297: wmap_cmp (weakmap.c:165)
    ==25795==    by 0x3A2B1C: find_table_bin_ind (st.c:930)
    ==25795==    by 0x3A5EAA: st_general_foreach (st.c:1599)
    ==25795==    by 0x3A5EAA: rb_st_foreach (st.c:1640)
    ==25795==    by 0x25C991: gc_mark_children (default.c:4870)
    ==25795==    by 0x25C991: gc_marks_wb_unprotected_objects_plane (default.c:5565)
    ==25795==    by 0x25C991: rgengc_rememberset_mark_plane (default.c:5557)
    ==25795==    by 0x25C991: rgengc_rememberset_mark (default.c:6233)
    ==25795==    by 0x25C991: gc_marks_start (default.c:6057)
    ==25795==    by 0x25C991: gc_marks (default.c:6077)
    ==25795==    by 0x25C991: gc_start (default.c:6723)
    ==25795==    by 0x260F96: heap_prepare (default.c:2282)
    ==25795==    by 0x260F96: heap_next_free_page (default.c:2489)
    ==25795==    by 0x260F96: newobj_cache_miss (default.c:2598)
    ==25795==    by 0x26197F: newobj_alloc (default.c:2622)
    ==25795==    by 0x26197F: rb_gc_impl_new_obj (default.c:2701)
    ==25795==    by 0x26197F: newobj_of (gc.c:890)
    ==25795==    by 0x26197F: rb_wb_protected_newobj_of (gc.c:917)
    ==25795==    by 0x2DEA88: rb_class_allocate_instance (object.c:131)
    ==25795==    by 0x2E3B18: class_call_alloc_func (object.c:2141)
    ==25795==    by 0x2E3B18: rb_class_alloc (object.c:2113)
    ==25795==    by 0x2E3B18: rb_class_new_instance_pass_kw (object.c:2172)
    ==25795==    by 0x429DDC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3786)
    ==25795==    by 0x44B08D: vm_sendish (vm_insnhelper.c:5953)
    ==25795==    by 0x44B08D: vm_exec_core (insns.def:898)
    ==25795==    by 0x43A7A4: rb_vm_exec (vm.c:2564)
    ==25795==    by 0x234914: rb_ec_exec_node (eval.c:281)
    ==25795==  Address 0x21603710 is 0 bytes inside a block of size 16 free'd
    ==25795==    at 0x4849B2C: free (vg_replace_malloc.c:989)
    ==25795==    by 0x249651: rb_gc_impl_free (default.c:8527)
    ==25795==    by 0x249651: rb_gc_impl_free (default.c:8508)
    ==25795==    by 0x249651: ruby_sized_xfree.constprop.0 (gc.c:4178)
    ==25795==    by 0x4626EC: ruby_sized_xfree_inlined (gc.h:277)
    ==25795==    by 0x4626EC: wmap_free_entry (weakmap.c:45)
    ==25795==    by 0x4626EC: wmap_mark_weak_table_i (weakmap.c:61)
    ==25795==    by 0x3A5CEF: apply_functor (st.c:1633)
    ==25795==    by 0x3A5CEF: st_general_foreach (st.c:1543)
    ==25795==    by 0x3A5CEF: rb_st_foreach (st.c:1640)
    ==25795==    by 0x25C991: gc_mark_children (default.c:4870)
    ==25795==    by 0x25C991: gc_marks_wb_unprotected_objects_plane (default.c:5565)
    ==25795==    by 0x25C991: rgengc_rememberset_mark_plane (default.c:5557)
    ==25795==    by 0x25C991: rgengc_rememberset_mark (default.c:6233)
    ==25795==    by 0x25C991: gc_marks_start (default.c:6057)
    ==25795==    by 0x25C991: gc_marks (default.c:6077)
    ==25795==    by 0x25C991: gc_start (default.c:6723)
    ==25795==    by 0x260F96: heap_prepare (default.c:2282)
    ==25795==    by 0x260F96: heap_next_free_page (default.c:2489)
    ==25795==    by 0x260F96: newobj_cache_miss (default.c:2598)
    ==25795==    by 0x26197F: newobj_alloc (default.c:2622)
    ==25795==    by 0x26197F: rb_gc_impl_new_obj (default.c:2701)
    ==25795==    by 0x26197F: newobj_of (gc.c:890)
    ==25795==    by 0x26197F: rb_wb_protected_newobj_of (gc.c:917)
    ==25795==    by 0x2DEA88: rb_class_allocate_instance (object.c:131)
    ==25795==    by 0x2E3B18: class_call_alloc_func (object.c:2141)
    ==25795==    by 0x2E3B18: rb_class_alloc (object.c:2113)
    ==25795==    by 0x2E3B18: rb_class_new_instance_pass_kw (object.c:2172)
    ==25795==    by 0x429DDC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3786)
    ==25795==    by 0x44B08D: vm_sendish (vm_insnhelper.c:5953)
    ==25795==    by 0x44B08D: vm_exec_core (insns.def:898)
    ==25795==    by 0x43A7A4: rb_vm_exec (vm.c:2564)
    ==25795==  Block was alloc'd at
    ==25795==    at 0x484680F: malloc (vg_replace_malloc.c:446)
    ==25795==    by 0x25CE9E: rb_gc_impl_malloc (default.c:8542)
    ==25795==    by 0x462A39: wmap_aset_replace (weakmap.c:423)
    ==25795==    by 0x3A5542: rb_st_update (st.c:1487)
    ==25795==    by 0x462B8E: wmap_aset (weakmap.c:452)
    ==25795==    by 0x429DDC: vm_call_cfunc_with_frame_ (vm_insnhelper.c:3786)
    ==25795==    by 0x44B08D: vm_sendish (vm_insnhelper.c:5953)
    ==25795==    by 0x44B08D: vm_exec_core (insns.def:898)
    ==25795==    by 0x43A7A4: rb_vm_exec (vm.c:2564)
    ==25795==    by 0x234914: rb_ec_exec_node (eval.c:281)
    ==25795==    by 0x2369B8: ruby_run_node (eval.c:319)
    ==25795==    by 0x15D675: rb_main (main.c:43)
    ==25795==    by 0x15D675: main (main.c:62)

* Fix use-after-free for WeakKeyMap

[Bug #20688]

We cannot free the key before the ST_DELETE because it could hash the
key which would read the key and would cause a use-after-free. Instead,
we store the key and free it on the next iteration.
2024-08-22 15:54:55 -07:00
Hiroshi SHIBATA 9ae91eb2aa
Backport warning feature for bundled gems from master (#11420)
* Make sure to always use the right `warn`

* lib/bundled_gems.rb: more reliable caller detection

The `2` skipped frames went out of sync and now it should be `3`.

Rather than just update the offset, we can implement a way that
is adaptative as long as all require decorators are also called require.

Also we should compute the corresponding `uplevel` otherwise the
warning will still point decorators.

Co-authored-by: "Hiroshi SHIBATA" <hsbt@ruby-lang.org>

* Warn ostruct for Ruby 3.5

* Warn pstore for Ruby 3.5

* Mark rdoc as bundled gems at Ruby 3.5

* Warn to use win32ole without Gemfile for Ruby 3.5

* EXACT list is mostly same as SINCE list on bundled gems.

* Mark to warn fiddle as bundled gems for Ruby 3.5

* Mark to warn logger as bundled gems for Ruby 3.5

* We should use uplevel:2 in another case.

Like the following scenario with bootsnap, that frames are same or smaller than frame_to_skip(=3).

---
"/Users/hsbt/.local/share/rbenv/versions/3.3-dev/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'"
"/Users/hsbt/.local/share/gem/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'"
"test_warn_bootsnap.rb:11:in `<main>'"
---

* Delete unnecessary rubocop disable comment

* Show correct script name with sub-feature case

* Skip to show script name with using ruby -r option

* Don't show script name when bundle exec and call ruby script directly.

* Pick word fix from 34adc07372

---------

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Co-authored-by: Kentaro Takeyama <75117116+obregonia1@users.noreply.github.com>
2024-08-21 09:40:11 -07:00
John Hawthorn 66312ad913
Re-initialize vm->ractor.sched.lock after fork (#11372)
[Bug #20633] Re-initialize vm->ractor.sched.lock after fork

Previously under certain conditions it was possible to encounter a
deadlock in the forked child process if ractor.sched.lock was held.

Co-authored-by: Nathan Froyd <froydnj@gmail.com>
2024-08-14 10:19:53 -07:00
Hiroshi SHIBATA 4d11a0960d Added bootstrap job for release workflow 2024-08-08 17:00:50 +08:00
Jean byroot Boussier 65cca99b30
parse.y: const_decl_path don't replace destination node by a literal (#11314)
[Bug #20668]

The `dest` node is assumed to be a `CDECL`, so overwriting it with
a `LIT` cause a crash on the next iteration.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-08-06 10:34:39 -07:00
Hiroshi SHIBATA f85c7deacc
Update RubyGems 3.5.16 and Bundler 2.5.16 for Ruby 3.3 (#11252)
* Merge RubyGems-3.5.12 and Bundler-2.5.12

* Merge RubyGems-3.5.13 and Bundler-2.5.13

* Merge RubyGems-3.5.14 and Bundler-2.5.14

* Merge RubyGems-3.5.15 and Bundler-2.5.15

* Merge RubyGems-3.5.16 and Bundler-2.5.16
2024-07-30 09:05:54 -07:00