summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-12-01Rework tracing for blocks running as methodsAlan Wu
The main impetus for this change is to fix [Bug #13392]. Previously, we fired the "return" TracePoint event after popping the stack frame for the block running as method (BMETHOD). This gave undesirable source location outputs as the return event normally fires right before the frame going away. The iseq for each block can run both as a block and as a method. To accommodate that, this commit makes vm_trace() fire call/return events for instructions that have b_call/b_return events attached when the iseq is running as a BMETHOD. The logic for rewriting to "trace_*" instruction is tweaked so that when the user listens to call/return events, instructions with b_call/b_return become trace variants. To continue to provide the return value for non-local returns done using the "return" or "break" keyword inside BMETHODs, the stack unwinding code is tweaked. b_return events now provide the same return value as return events for these non-local cases. A pre-existing test deemed not providing a return value for these b_return events as a limitation. This commit removes the checks for call/return TracePoint events that happen when calling into BMETHODs when no TracePoints are active. Technically, migrating just the return event is enough to fix the bug, but migrating both call and return removes our reliance on `VM_FRAME_FLAG_FINISH` and re-entering the interpreter when the caller is already in the interpreter. Notes: Merged: https://github.com/ruby/ruby/pull/4637
2021-12-01Revert "Force disable yjit on OpenBSD"Aaron Patterson
This reverts commit 119626da947bf6492ef7a27abf3bf12de5d0d95a.
2021-12-01Check that cb / ocb exist before marking executableAaron Patterson
If YJIT isn't enabled, or hasn't finished booting, cb / ocb could be null. This commit just checks to make sure they're available before marking as executable Co-Authored-By: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-Authored-By: Kevin Newton <kddnewton@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/5032
2021-12-01Mark JIT code as writeable / executable depending on the situationAaron Patterson
Some platforms don't want memory to be marked as writeable and executable at the same time. When we write to the code block, we calculate the OS page that the buffer position maps to. Then we call `mprotect` to allow writes on that particular page. As an optimization, we cache the "last written" aligned page which allows us to amortize the cost of the `mprotect` call. In other words, sequential writes to the same page will only call `mprotect` on the page once. When we're done writing, we call `mprotect` on the entire JIT buffer. This means we don't need to keep track of which pages were marked as writeable, we let the OS take care of that. Co-authored-by: John Hawthorn <john@hawthorn.email> Notes: Merged: https://github.com/ruby/ruby/pull/5032
2021-12-02[rubygems/rubygems] Provide distinguished name which will be correctly parsed.Vít Ondruch
It seems that since ruby openssl 2.1.0 [[1]], the distinguished name submitted to `OpenSSL::X509::Name.parse` is not correctly parsed if it does not contain the first slash: ~~~ $ ruby -v ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux] $ gem list | grep openssl openssl (default: 2.2.0) $ irb -r openssl irb(main):001:0> OpenSSL::X509::Name.parse("CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE) => "CN = nobody/DC=example" irb(main):002:0> OpenSSL::X509::Name.parse("/CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE) => "CN = nobody, DC = example" ~~~ Instead, use `OpenSSL::X509::Name.new` directly as suggested by upstream maintainer. [1]: https://github.com/ruby/openssl/commit/19c67cd10c57f3ab7b13966c36431ebc3fdd653b https://github.com/rubygems/rubygems/commit/09ca0c2dae Co-authored-by: Kazuki Yamaguchi <k@rhe.jp>
2021-12-02* 2021-12-02 [ci skip]git
2021-12-01YJIT: Fail gracefully while OOM for new entry pointsAlan Wu
Previously, YJIT crashes with rb_bug() when asked to compile new methods while out of executable memory. To handle this situation gracefully, this change keeps track of all the blocks compiled each invocation in case YJIT runs out of memory in the middle of a compliation sequence. The list is used to free all blocks in case compilation fails. yjit_gen_block() is renamed to gen_single_block() to make it distinct from gen_block_version(). Call to limit_block_version() and block_t allocation is moved into the function to help tidy error checking in the outer loop. limit_block_version() now returns by value. I feel that an out parameter with conditional mutation is unnecessarily hard to read in code that does not need to go for last drop performance. There is a good chance that the optimizer is able to output identical code anyways. Notes: Merged: https://github.com/ruby/ruby/pull/5191
2021-12-01[win32] skip example about STDIN encodingsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5196
2021-12-01[win32] Transcode input from console [Bug #18353]Nobuyoshi Nakada
On Windows, as the input from console is encoded in the active code page, convert the input to the internal encoding. Notes: Merged: https://github.com/ruby/ruby/pull/5196
2021-12-01Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbdHiroshi SHIBATA
2021-12-01Removed vcr files. They are needless for this repoHiroshi SHIBATA
2021-12-01* 2021-12-01 [ci skip]git
2021-12-01[rubygems/rubygems] Update ↵Olle Jonsson
bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt https://github.com/rubygems/rubygems/commit/8836fe157b Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2021-12-01[rubygems/rubygems] Update main.yml.ttOlle Jonsson
https://github.com/rubygems/rubygems/commit/3260173c59
2021-12-01[rubygems/rubygems] newgem tmpl: ruby as "2.7" in GH Actions matrixOlle Jonsson
https://github.com/rubygems/rubygems/commit/f5bead5634
2021-12-01[rubygems/rubygems] newgem templ: Avoid Float 3.0 -> "3" in GH ActionOlle Jonsson
This change avoids a YAML Float-to-String conversion, which turns a 3.0 into a "3". That can make names of builds less clear. In order to use this new capability, I added a "name" descriptor to the matrix-created Job. https://github.com/rubygems/rubygems/commit/6221241ad4
2021-11-30[rubygems/rubygems] Fix race condition when reading & writing gemspecs ↵David Rodríguez
concurrently When bundler parallel installer installs gems concurrently, one can get confusing warnings like the following: ``` "[/home/runner/work/rubygems/rubygems/bundler/tmp/2/gems/system/specifications/zeitwerk-2.4.2.gemspec] isn't a Gem::Specification (NilClass instead). ``` I've got these warnings several times in the past, but I never managed to reproduce them, and never look deeply into the root cause, but this time a got a cause that reproduced quite frequently, so I looked into it. The problem is one thread reading a gemspec while another thread is writing it. The write of the gemspec was not protected, so `Gem::Specification.load` could end up seeing a truncated gemspec and thus throw this warning. The fix involve two changes: * Change the methods that write gemspecs to use `Gem.binary_write` which is protected by a lock. * Fix `Gem.binary_write` to create the file lock at file creation time, not when the file already exists after. The realworld user problem caused by this issue happens in bundler, but I'm fixing it in rubygems first, and then I'll backport to bundler whatever needs backporting to fix the issue on the bundler side. https://github.com/rubygems/rubygems/commit/a672e7555c
2021-11-30[rubygems/rubygems] Revert "Remove spec file before building"David Rodríguez
This reverts commit af604436d8141c34cb2e1e645b9b0d47bfd55a55. The issue that led to introducing it was never reproduced. I tried to repro with this patch and it still works just fine. Since this removal is getting in the middle for some race conditions I'm facing, I'm reverting the patch. https://github.com/rubygems/rubygems/commit/2dd267f0e4
2021-11-30[rubygems/rubygems] Run hooks tests on gemspecs not already installedDavid Rodríguez
The current `setup_base_installer` ends up using the `quick_gem` helper, which leaves the created specification installed. Instead, make sure to use the `util_spec` helper, which does a similar thing but doesn't leave the specification installed. The idea is that tests do not rely on the installer removing existing gemspecs, bacause I plan to stop doing that. https://github.com/rubygems/rubygems/commit/843f1a0abc
2021-11-30Delete #if line during checking madvise() on SolarisNaohisa Goto
The madvise() declaration should always be compiled on Solaris to check whether the declaration is good on the environment. For the purpose, the #if line is unnecessary. (There was also a trivial typo that the #if was not closed by #endif and the check always failed with preprocessor error.)
2021-11-30Let pretty_inspect work once at firstNobuyoshi Nakada
For older pp.rb which did not need io/console, and dealing with `LoadError`.
2021-11-30[ruby/error_highlight] Ignore all syscall errorsYusuke Endoh
At least, Error::ENOTSUP may be raised on some extreme environments https://github.com/ruby/error_highlight/commit/2787983ff7
2021-11-30lib/pp.rb (width_for): Ignore all syscall errorsYusuke Endoh
According to nobu, Errno::EBAD is raised on Windows.
2021-11-30lib/pp.rb (width_for): ignore Errno::EINVALYusuke Endoh
The error is raised on Solaris http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20211130T030003Z.fail.html.gz ``` 1) Failure: TestRubyOptions#test_require [/export/home/users/chkbuild/cb-gcc/tmp/build/20211130T030003Z/ruby/test/ruby/test_rubyoptions.rb:265]: pid 7386 exit 1 | /export/home/users/chkbuild/cb-gcc/tmp/build/20211130T030003Z/ruby/lib/pp.rb:67:in `winsize': Invalid argument - <STDOUT> (Errno::EINVAL) ```
2021-11-30Load io/console earlierNobuyoshi Nakada
Something goes wrong at loading libraries inside `mu_pp` in the test overriding `Class.inherited`.
2021-11-30Recent systems prohibit symlink for relative loadingNobuyoshi Nakada
2021-11-30Enable load-relative on SolarisNobuyoshi Nakada
2021-11-30lib/pp.rb (PP.pp): Use io/console's winsize by defaultYusuke Endoh
[Feature #12913]
2021-11-30Cache wheather madvise declaration is needed on SolarisNobuyoshi Nakada
2021-11-30Fix conflicting declaration on SolarisNobuyoshi Nakada
SunC ``` "cont.c", line 24: identifier redeclared: madvise current : function(pointer to char, unsigned int, int) returning int previous: function(pointer to void, unsigned int, int) returning int : "/usr/include/sys/mman.h", line 232 ``` GCC ``` cont.c:24:12: error: conflicting types for 'madvise' 24 | extern int madvise(caddr_t, size_t, int); | ^~~~~~~ In file included from cont.c:16: /usr/include/sys/mman.h:232:12: note: previous declaration of 'madvise' was here 232 | extern int madvise(void *, size_t, int); | ^~~~~~~ ```
2021-11-30Fix `GC.total_time` exampleNobuyoshi Nakada
The result may increase actually or not, since GC can finish shorter than the timer granularity. Notes: Merged: https://github.com/ruby/ruby/pull/5193 Merged-By: nobu <nobu@ruby-lang.org>
2021-11-30[rubygems/rubygems] Fix escape of filenames in `bundle doctor`ooooooo-q
https://github.com/rubygems/rubygems/commit/3ede1435ea
2021-11-30* 2021-11-30 [ci skip]git
2021-11-30Revert "test/socket/test_socket.rb: skip on Solaris"Naohisa Goto
This reverts commit 27fb9d272daaae89089dfb61849ebe8e7aa6c833. The test failure on Solaris 10 is due to incomplete IPv6 configuration on the CI server, that have already been fixed. Reference for the fix: https://centrify.force.com/support/Article/KB-1179-X11-Forwarding-fails-with-Centrify-OpenSSH-5-0-Solaris/
2021-11-30Workaround for implicit declaration of function 'madvise' on SolarisNaohisa Goto
On Solaris, madvise(3C) is NOT defined for SUS (XPG4v2) or later, but MADV_* macros are defined when __EXTENSIONS__ is defined. This may cause compile error on Solaris 10 with GCC when "-Werror=implicit-function-declaration" and "-D_XOPEN_SOURCE=600" are added by configure.
2021-11-29Update to ruby/spec@7f22a0bBenoit Daloze
2021-11-29Update to ruby/mspec@098b320Benoit Daloze
2021-11-29[ci skip] Update documentation for GC.statPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/5189
2021-11-29[rubygems/rubygems] Deprecate typo nameNobuyoshi Nakada
https://github.com/rubygems/rubygems/commit/62d54cbf08
2021-11-29Simplify platform check for Windows-UCRTLars Kanis
RUBY_PLATFORM can be used since commit 576b2e64cdc5ea42ad345dd3c1c215e006c06fca . Notes: Merged: https://github.com/ruby/ruby/pull/5168
2021-11-29Consider environment variable case-insensitivenessNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5188
2021-11-29* 2021-11-29 [ci skip]git
2021-11-29[ruby/readline] Suppress constant redefinition warningNobuyoshi Nakada
When already set by `use_lib_reline` in test/readline/helper.rb of readline-ext. https://github.com/ruby/readline/commit/0e3ca3b217
2021-11-28Suppress address-of-packed-member warning by gccNobuyoshi Nakada
2021-11-28[ruby/ostruct] [DOC] Fix code markups [ci skip]Nobuyoshi Nakada
Backquotes are not special characters in RDoc. https://github.com/ruby/ostruct/commit/a901df26b9
2021-11-28* 2021-11-28 [ci skip]git
2021-11-27Enhanced RDoc for numeric.c (#5184)Burdette Lamar
Adds remarks about literals and Kernel methods to Float and Integer. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-11-27[ruby/cgi] Exclude unused files from built packageNobuyoshi Nakada
https://github.com/ruby/cgi/commit/e840b6c368
2021-11-27[ruby/cgi] Set extconf.rb to extensionsNobuyoshi Nakada
Fix https://github.com/ruby/cgi/pull/11 https://github.com/ruby/cgi/commit/60d8f5e7d9
2021-11-26YJIT: Add ability to exit to interpreter from stubsAlan Wu
Previously, YJIT assumed that it's always possible to generate a new basic block when servicing a stub in branch_stub_hit(). When YJIT is out of executable memory, for example, this assumption doesn't hold up. Add handling to branch_stub_hit() for servicing stubs without consuming more executable memory by adding a code path that exits to the interpreter at the location the branch stub represents. The new code path reconstructs interpreter state in branch_stub_hit() and then exits with a new snippet called `code_for_exit_from_stub` that returns `Qundef` from the YJIT native stack frame. As this change adds another place where we regenerate code from `branch_t`, extract the logic for it into a new function and call it regenerate_branch(). While we are at it, make the branch shrinking code path in branch_stub_hit() more explicit. This new functionality is hard to test without full support for out of memory conditions. To verify this change, I ran `RUBY_YJIT_ENABLE=1 make check -j12` with the following patch to stress test the new code path: ```diff diff --git a/yjit_core.c b/yjit_core.c index 4ab63d9806..5788b8c5ed 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -878,8 +878,12 @@ branch_stub_hit(branch_t *branch, const uint32_t target_idx, rb_execution_contex cb_set_write_ptr(cb, branch->end_addr); } +if (rand() < RAND_MAX/2) { // Compile the new block version p_block = gen_block_version(target, target_ctx, ec); +}else{ + p_block = NULL; +} if (!p_block && branch_modified) { // We couldn't generate a new block for the branch, but we modified the branch. ``` We can enable the new test along with other OOM tests once full support lands. Other small changes: * yjit_utils.c (print_str): Update to work with new native frame shape. Follow up for 8fa0ee4d404. * yjit_iface.c (rb_yjit_init): Run yjit_init_core() after yjit_init_codegen() so `cb` and `ocb` are available. Notes: Merged: https://github.com/ruby/ruby/pull/5180 Merged-By: XrXr