summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-12-07Eliminate array allocation for f(1, *a, &lvar) and f(1, *a, &@iv)Jeremy Evans
Due to how the compiler works, while f(*a, &lvar) and f(*a, &@iv) do not allocate an array, but f(1, *a, &lvar) and f(1, *a, &@iv) do. It's probably possible to fix this in the compiler, but seems easiest to fix this in the peephole optimizer. Eliminating this array allocation is as safe as the current elimination of the array allocation for f(*a, &lvar) and f(*a, &@iv).
2023-12-07Eliminate array allocation for f(1, *a)Jeremy Evans
Due to how the compiler works, while f(*a) does not allocate an array f(1, *a) does. This is possible to fix in the compiler, but the change is much more complex. This attempts to fix the issue in a simpler way using the peephole optimizer. Eliminating this array allocation is safe, since just as in the f(*a) case, nothing else on the caller side can modify the array.
2023-12-07[PRISM] Stop catch table entries being deleted by the optimiserMatt Valentine-House
2023-12-07Support tracing of struct member accessor methodsJeremy Evans
This follows the same approach used for attr_reader/attr_writer in 2d98593bf54a37397c6e4886ccc7e3654c2eaf85, skipping the checking for tracing after the first call using the call cache, and clearing the call cache when tracing is turned on/off. Fixes [Bug #18886]
2023-12-07Skip a flaky objspace test on Visual StudioTakashi Kokubun
This seems to happen only on VisualStudio: https://github.com/ruby/ruby/actions/runs/7130917319/job/19418375386 It fails relatively frequently. Nobody seems actively working on it, so let's skip it until somebody starts working on it.
2023-12-07Support eval "return" at toplevelJeremy Evans
Since Ruby 2.4, `return` is supported at toplevel. This makes `eval "return"` also supported at toplevel. This mostly uses the same tests as direct `return` at toplevel, with a couple differences: `END {return if false}` is a SyntaxError, but `END {eval "return" if false}` is not an error since the eval is never executed. `END {return}` is a SyntaxError, but `END {eval "return"}` is a LocalJumpError. The following is a SyntaxError: ```ruby class X nil&defined?0--begin e=no_method_error(); return; 0;end end ``` However, the following is not, because the eval is never executed: ```ruby class X nil&defined?0--begin e=no_method_error(); eval "return"; 0;end end ``` Fixes [Bug #19779]
2023-12-07Use free with ruby_dtoaJohn Hawthorn
In ae0ceafb0c0d05cc80623b525070255e3abb34ef ruby_dtoa was switched to use malloc instead of xmalloc, which means that consumers should be using free instead of xfree. Otherwise we will artificially shrink oldmalloc_increase_bytes.
2023-12-07Use xfree in hash_st_freeJohn Hawthorn
st.c redefines malloc and free to be ruby_xmalloc and ruby_xfree, so when this was copied into hash.c it ended up mismatching an xmalloc with a regular free, which ended up inflating oldmalloc_increase_bytes when hashes were freed by minor GC.
2023-12-07Fix keyword splat passing as regular argumentJeremy Evans
Since Ruby 3.0, Ruby has passed a keyword splat as a regular argument in the case of a call to a Ruby method where the method does not accept keyword arguments, if the method call does not contain an argument splat: ```ruby def self.f(obj) obj end def self.fs(*obj) obj[0] end h = {a: 1} f(**h).equal?(h) # Before: true; After: false fs(**h).equal?(h) # Before: true; After: false a = [] f(*a, **h).equal?(h) # Before and After: false fs(*a, **h).equal?(h) # Before and After: false ``` The fact that the behavior differs when passing an empty argument splat makes it obvious that something is not working the way it is intended. Ruby 2 always copied the keyword splat hash, and that is the expected behavior in Ruby 3. This bug is because of a missed check in setup_parameters_complex. If the keyword splat passed is not mutable, then it points to an existing object and not a new object, and therefore it must be copied. Now, there are 3 specs for the broken behavior of directly using the keyword splatted hash. Fix two specs and add a new version guard. Do not keep the specs for the broken behavior for earlier Ruby versions, in case this fix is backported. For the ruby2_keywords spec, just remove the related line, since that line is unrelated to what the spec is testing. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-12-08Fix typo in a comment [ci skip]Nobuyoshi Nakada
2023-12-07Fix potential compaction issue in env_copy()Alan Wu
`src_ep[VM_ENV_DATA_INDEX_ME_CREF]` was read out and held without marking across the allocation in vm_env_new(). In case vm_env_new() ran compaction, an invalid reference could have been written into `copied_env`. It might've been hard to actually produce a crash with this issue due to the pinning marking of the field in rb_execution_context_mark().
2023-12-07Add missing write barrier to env_copy()Alan Wu
Previously, the following crashed with `vm_assert_env:imemo_type_p(obj, imemo_env)` due to missing a missing WB: o = Object.new def o.foo(n) freeze GC.stress = 1 # inflate block nesting get an imemo_env for each level n.tap do |i| i.tap do |local| return Ractor.make_shareable(-> do local + i + n end) end end ensure GC.stress = false GC.verify_internal_consistency end p o.foo(1)[] By the time the recursive env_copy() call returns, `copied_env` could have aged or have turned greyed, so we need a WB for the `ep[VM_ENV_DATA_INDEX_SPECVAL]` assignment which adds an edge. Fix: 674eb7df7f409099f33da77293d9658e09b470d6
2023-12-07[ruby/irb] Debugging command warning should not be specific to theStan Lo
`debug` command (https://github.com/ruby/irb/pull/806) https://github.com/ruby/irb/commit/b7b57311cc
2023-12-07[ruby/prism] Update ordering of integer base flagsKevin Newton
https://github.com/ruby/prism/commit/d711950d5f
2023-12-07Check need_major_gc during GC stressPeter Zhu
need_major_gc is set when a major GC is required. However, if gc_stress_no_major is also set, then it will not actually run a major GC. For example, the following script will sometimes crash: ``` GC.stress = 1 50000.times.map { [] } ``` With the following message: ``` [BUG] cannot create a new page after major GC ```
2023-12-07[PRISM] Don't pop arguments on a return nodeJemma Issroff
Since ReturnNodes don't get popped, their arguments shouldn't either
2023-12-07Fix GC.verify_compaction_references not moving every objectKJ Tsanaktsidis
The intention of GC.verify_compaction_references is, I believe, to force every single movable object to be moved, so that it's possible to debug native extensions which not correctly updating their references to objects they mark as movable. To do this, it doubles the number of allocated pages for each size pool, and sorts the heap pages so that the free ones are swept first; thus, every object in an old page should be moved into a free slot in one of the new pages. This worked fine until movement of objects _between_ size pools during compaction was implemented. That causes some problems for verify_compaction_references: * We were doubling the number of pages in each size pool, but actually if some objects need to move into a _different_ pool, there's no guarantee that they'll be enough room in that one. * It's possible for the sweep & compact cursors to meet in one size pool before all the objects that want to move into that size pool from another are processed by the compaction. You can see these problems by changing some of the movement tests in test_gc_compact.rb to try and move e.g. 50,000 objects instead of 500; the test is not able to actually move all of the objects in a single compaction run. To fix this, we do two things in verify_compaction_references: * Firstly, we add enough pages to every size pool to make them the same size. This ensures that their compact cursors will all have space to move during compaction (even if that means empty pages are pointlessly compacted) * Then, we examine every object and determine where it _wants_ to be compacted into. We use this information to add additional pages to each size pool to handle all objects which should live there. With these two changes, we can move arbitrary amounts of objects into the correct size pool in a single call to verify_compaction_references. My _motivation_ for performing this work was to try and fix some test stability issues in test_gc_compact.rb. I now no longer think that we actually see this particular bug in rubyci.org, but I also think verify_compaction_references should do what it says on the tin, so it's worth keeping. [Bug #20022]
2023-12-07Add objspace_each_pages to gc.cKJ Tsanaktsidis
This works like objspace_each_obj, except instead of being called with the start & end address of each page, it's called with the page structure itself. [Bug #20022]
2023-12-07[ruby/prism] Remove warnings check from parse_success? methodKevin Newton
https://github.com/ruby/prism/commit/e30a241fb3
2023-12-07[PRISM] Ensure should set correct end_labelMatt Valentine-House
2023-12-07[PRISM] Rescue should set correct end_labelMatt Valentine-House
In order for a break inside the rescue to have the correct jump target
2023-12-07Lrama v0.5.12yui-knk
2023-12-07NEWS: Move "interruptible name resolution" to "Stdlib updates" sectionYusuke Endoh
2023-12-07[ruby/io-console] [DOC] Add documentation for IO#cursorMatheus Richard
ruby/io-console#50 https://github.com/ruby/io-console/commit/ee752ce771
2023-12-07Update bundled gems list at bc6a0ede4a05d19dc999d05c84b46a [ci skip]git
2023-12-07Bump up bundled net-ftp gem version to 0.3.0Hiroshi SHIBATA
2023-12-07Sort links [ci skip]Kazuhiro NISHIYAMA
2023-12-07always omit test_ai_addrconfig.Tanaka Akira
2023-12-07Set AI_ADDRCONFIG when making getaddrinfo(3) calls for outgoing conns (#7295)KJ Tsanaktsidis
When making an outgoing TCP or UDP connection, set AI_ADDRCONFIG in the hints we send to getaddrinfo(3) (if supported). This will prompt the resolver to _NOT_ issue A or AAAA queries if the system does not actually have an IPv4 or IPv6 address (respectively). This makes outgoing connections marginally more efficient on non-dual-stack systems, since we don't have to try connecting to an address which can't possibly work. More importantly, however, this works around a race condition present in some older versions of glibc on aarch64 where it could accidently send the two outgoing DNS queries with the same DNS txnid, and get confused when receiving the responses. This manifests as outgoing connections sometimes taking 5 seconds (the DNS timeout before retry) to be made. Fixes #19144
2023-12-07Revert "Warn `it` only with -W:deprecated"Takashi Kokubun
This reverts commit 5458252bb0edcd498e6bd4bea57fd7500bacd54c. Revert "Fallback rb_warn_deprecated for UNIVERSAL_PARSER" This reverts commit 680be886f4d807073f24beed36648ef76219e4f7. matz actually preferred always warning `it`.
2023-12-07Fallback rb_warn_deprecated for UNIVERSAL_PARSERTakashi Kokubun
2023-12-06Warn `it` only with -W:deprecatedTakashi Kokubun
2023-12-07Update default gems list at a41d6c825c4b1ed5699fd7880edeb8 [ci skip]git
2023-12-07[ruby/open-uri] Bump up 0.4.1Hiroshi SHIBATA
https://github.com/ruby/open-uri/commit/d72508a7f4
2023-12-07Warn `it` (#9152)Takashi Kokubun
https://bugs.ruby-lang.org/issues/18980
2023-12-07[ruby/open-uri] Set default for max_redirects and add exception classAndrew Kane
https://github.com/ruby/open-uri/commit/dcdcb885cc
2023-12-07[ruby/open-uri] Add :max_redirects optionAndrew Kane
https://github.com/ruby/open-uri/commit/7fd5ea09a7
2023-12-07[rubygems/rubygems] Make --build-root disable auto-user-install.Ellen Marie Dash
https://github.com/rubygems/rubygems/commit/6a06b0763f
2023-12-07[rubygems/rubygems] Better approach to falling back to user installation ↵David Rodríguez
when GEM_HOME not writable https://github.com/rubygems/rubygems/commit/f67bced16b
2023-12-07[rubygems/rubygems] Add some early assertions to make sure the test is ↵David Rodríguez
progressing fine If an error happens during the install command, it will fail in an strange way right now. https://github.com/rubygems/rubygems/commit/2b6e0c703a
2023-12-07[rubygems/rubygems] Use globals variables for standard input/outputVít Ondruch
Replace use of `STDIN`, `STDOUT` and `STDERR` constants by their `$stdin`, `$stdout` and `$stderr` global variable equivalents. This enables easier testing via standard means, such as `assert_output` for minitest or `expect { print 'foo' }.to output.to_stdout` for RSpec test suites. https://github.com/rubygems/rubygems/commit/a0a6fc1b76
2023-12-06Copy encoding flags when copying a regex [Bug #20039]Dustin Brown
* :bug: Fixes [Bug #20039](https://bugs.ruby-lang.org/issues/20039) When a Regexp is initialized with another Regexp, we simply copy the properties from the original. However, the flags on the original were not being copied correctly. This caused an issue when the original had multibyte characters and was being compared with an ASCII string. Without the forced encoding flag (`KCODE_FIXED`) transferred on to the new Regexp, the comparison would fail. See the included test for an example. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-12-07Remove a note for `bundle exec ruby` not printing a warningYusuke Endoh
The implementation limitation is fixed by https://github.com/rubygems/rubygems/pull/7224
2023-12-07Move replace_require into bundled_gems.rbHiroshi SHIBATA
2023-12-07Fix SEGV caused by `GC::Profiler.raw_data` (#9122)Soutaro Matsumoto
2023-12-07Add NEWS for Range#overlap?hogelog
2023-12-06[ruby/prism] Emit error for constant assignments in defsHaldun Bayhantopcu
https://github.com/ruby/prism/commit/864b06f90e
2023-12-06YJIT: Add some object validity assertionsAlan Wu
We've seen quite a few compaction bugs lately, and these assertions should give clearer symptoms. We only call class_of() on objects that the Ruby code can see.
2023-12-06[ruby/prism] Simplify unterminated stringKevin Newton
https://github.com/ruby/prism/commit/ef512ca914
2023-12-06[PRISM] Correct depth offset for block local varsMatt Valentine-House
Blocks should always look at their own local table first, even when defined inside an ensure/rescue or something else that uses depth offset. We can ignore the depth offset if we're doing local lookups inside a block