Commit graph

16692 commits

Author SHA1 Message Date
Nobuyoshi Nakada
66a9e452bb [ruby/rdoc] Use runnable command as DUMMY_PAGER
fec1ab2e41
2022-06-06 21:19:45 +09:00
Pavel Rosický
4bc7cef866
[ruby/cgi] jruby support
93326fb622
2022-06-06 18:13:01 +09:00
Yusuke Endoh
5d014bcb61 Use sleep 0.5 for tests of GVL instrumentation API
The tests fail randomly on some platforms.

20220605T213004Z.fail.html.gz
20220605T210003Z.fail.html.gz
```
[15737/21701] TestThreadInstrumentation#test_thread_instrumentation_fork_safe/home/chkbuild/chkbuild/tmp/build/20220605T213004Z/ruby/tool/lib/test/unit/assertions.rb:109:in `assert': Expected 0 to be nonzero?. (Test::Unit::AssertionFailedError)
```

The failures seem to depend on context switches. I suspect `sleep 0.05`
is too short, so this change tries to extend the wait time.
2022-06-06 12:52:15 +09:00
Nobuyoshi Nakada
9a7be959b1 [ruby/rdoc] Remove RDoc::RI::Driver#in_path?
83051403d6
2022-06-04 16:42:10 +09:00
Nobuyoshi Nakada
d4c7e4d5bb [ruby/rdoc] Enable pager tests
ce63794fde
2022-06-04 16:42:09 +09:00
Jean Boussier
9125374726 [Feature #18339] GVL Instrumentation API
Ref: https://bugs.ruby-lang.org/issues/18339

Design:

- This tries to minimize the overhead when no hook is registered.
  It should only incur an extra unsynchronized boolean check.
- The hook list is protected with a read-write lock as to cause
  contention when some hooks are registered.
- The hooks MUST be thread safe, and MUST NOT call into Ruby as they
  are executed outside the GVL.
- It's simply a noop on Windows.

API:

```
rb_internal_thread_event_hook_t * rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data);
bool rb_internal_thread_remove_event_hook(rb_internal_thread_event_hook_t * hook);
```

You can subscribe to 3 events:

  - READY: called right before attempting to acquire the GVL
  - RESUMED: called right after successfully acquiring the GVL
  - SUSPENDED: called right after releasing the GVL.

The hooks MUST be threadsafe, as they are executed outside of the GVL, they also MUST NOT call any Ruby API.
2022-06-03 15:13:33 +02:00
Nobuyoshi Nakada
b96a3a6fd2
Move GC.verify_compaction_references [Bug #18779]
Define `GC.verify_compaction_references` as a built-in ruby method,
according to GC compaction support via `GC::OPTS`.
2022-06-02 15:32:00 +09:00
Nobuyoshi Nakada
9108db961d
Fix the condition when a new buffer is needed without GMP 2022-06-02 10:29:53 +09:00
David Rodríguez
8381c568e7 [rubygems/rubygems] Restore ability to load old marshalled gemspec that use YAML::PrivateType
This issue was not detected because when all traces of old YAML parser
and emitter `Syck` were removed, this null-type.gemspec.rz marshalled
gemspec was updated to no longer load `YAML::Syck::PrivateType` but load
`Psych::PrivateType` instead.

However, realworld old marshalled gemspecs still use the
`YAML::PrivateType` constant, so this commit replaces the gemspec to be
the real pry-0.4.7 marshalled gemspec, so that it catches this issue.

51b330b8d2
2022-06-01 17:06:52 +09:00
David Rodríguez
89ec3def74 [rubygems/rubygems] Improve null private type test
This test is making sure that RubyGems is able to load old marshalled
gemspecs that include a field loading `YAML::PrivateType` instances in
the `rubyforge_project` field instead of `nil` due to a bug in old YAML
emitters.

At some point, the `rubyforge_project` field was removed and this test
was updated to just check another field. However, in the realworld other
fields do not have this issue and the marshalled gemspec we use for
testing still has this issue in the field reserved for the
`rubyforge_project` field. So I think updating the test to check other
field was not correct.

Instead, since the `rubyforge_project` field is now ignored, we no
longer need to worry about any conversion in this field. The only thing
we care about is that the marshal loading still works (which requires
that the constant is at least defined).

So this commit updates the test to make this more clear.

cddfacf6d4
2022-06-01 17:06:52 +09:00
Hiroshi SHIBATA
0cae30e1d3
Skip failing test with freebsd 2022-05-31 11:40:38 +09:00
dependabot[bot]
360c5fd6f9 [rubygems/rubygems] Bump rb-sys in /test/rubygems/test_gem_ext_cargo_builder/custom_name
Bumps [rb-sys](https://github.com/ianks/rb-sys) from v0.7.3 to v0.9.0.
- [Release notes](https://github.com/ianks/rb-sys/releases)
- [Commits](e4f00b9761)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

874bbc96b2
2022-05-31 08:43:33 +09:00
dependabot[bot]
7a0e681426 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/ianks/rb-sys) from v0.7.3 to v0.9.0.
- [Release notes](https://github.com/ianks/rb-sys/releases)
- [Commits](e4f00b9761)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

eb31b14a37
2022-05-31 07:10:28 +09:00
Alan Wu
a687756284 Fix use-after-free with interacting TracePoints
`vm_trace_hook()` runs global hooks before running local hooks.
Previously, we read the local hook list before running the global hooks
which led to use-after-free when a global hook frees the local hook
list. A global hook can do this by disabling a local TracePoint, for
example.

Delay local hook list loading until after running the global hooks.

Issue discovered by Jeremy Evans in GH-5862.

[Bug #18730]
2022-05-30 13:54:22 -04:00
Hiroshi SHIBATA
a78f003c30
Skip failing test with freebsd 2022-05-30 18:40:31 +09:00
Nobuyoshi Nakada
d3e986d9ab [ruby/stringio] Accept external and internal encodings pair
Fix https://github.com/ruby/stringio/pull/16

c8a69e80d2
2022-05-30 14:48:44 +09:00
Hiroshi SHIBATA
4cc880e994
Also skip failing test with freebsd 12 2022-05-30 14:28:32 +09:00
Jeremy Evans
609d73e892 [ruby/stringio] Fix handling of chomp with paragraph separator
Try to mirror IO behavior, where chomp takes out the entire paragraph
separators between entries, but does not chomp a single line separator
at the end of the string.

Partially Fixes [Bug #18768]

a83ddbb7f0
2022-05-30 13:10:46 +09:00
Jeremy Evans
adaaf12857 [ruby/stringio] Ignore chomp keyword for nil separator
nil separator means no separator at all, so nothing should be
chomped.

Partial fix for Ruby [Bug #18770]

feaa2ec631
2022-05-30 13:01:17 +09:00
Jeremy Evans
1f82269f4e [ruby/stringio] Fix each with multiple character string and chomp
Previously, this could result in an infinite loop.  Always update
the e pointer in this case, setting w when chomping so the chomped
data is not included in the output.

Fixes [Bug #18769]

4bf64d5130
2022-05-30 12:55:47 +09:00
Nobuyoshi Nakada
bb6357cddd [ruby/stringio] Fix expanding size at ungetc/ungetbyte
a35268a3ac
2022-05-30 12:51:37 +09:00
Hiroshi SHIBATA
cc63718694
Skip failing test with freebsd 2022-05-30 10:53:45 +09:00
David Rodríguez
e78c1ddb1e [rubygems/rubygems] Fix rubygems update when non default --install-dir is configured
9f3b21192d
2022-05-28 19:22:15 +09:00
Samuel Williams
d875445e8a Fix GC race condition in autoload. 2022-05-26 00:17:30 +12:00
Samuel Williams
42bcc629fb Retain reference to blocking fibers. 2022-05-25 15:24:24 +12:00
Mike Dalessio
0c36ba5319 Define unsupported GC compaction methods as rb_f_notimplement
Fixes [Bug #18779]

Define the following methods as `rb_f_notimplement` on unsupported
platforms:

- GC.compact
- GC.auto_compact
- GC.auto_compact=
- GC.latest_compact_info
- GC.verify_compaction_references

This change allows users to call `GC.respond_to?(:compact)` to
properly test for compaction support. Previously, it was necessary to
invoke `GC.compact` or `GC.verify_compaction_references` and check if
those methods raised `NotImplementedError` to determine if compaction
was supported.

This follows the precedent set for other platform-specific
methods. For example, in `process.c` for methods such as
`Process.fork`, `Process.setpgid`, and `Process.getpriority`.
2022-05-24 09:40:03 -07:00
Yusuke Endoh
663915ddf4 [rubygems/rubygems] Support the change of did_you_mean about Exception#detailed_message
I am asking did_you_mean to use Exception#detailed_message to add
"Did you mean?" suggestion instead of overriding #message method.

https://github.com/ruby/did_you_mean/pull/177

Unfortunately, the change will affect Gem::UnknownCommandError, which
excepts did_you_mean to override #message method.

This PR absorbs the change of did_you_mean.
Gem::CommandManager now calls #detailed_message method to get a message
string with "Did you mean?" suggestion from an exception.

8f104228d3
2022-05-23 20:51:17 +09:00
Yusuke Endoh
0293f8ca8e Prevent a warning: `*' interpreted as argument prefix 2022-05-23 17:33:52 +09:00
Takashi Kokubun
8b2ff2acdd
Make the test class naming consistent
forgot to commit this in ead96e7b44
2022-05-20 21:34:47 -07:00
Takashi Kokubun
ead96e7b44
Rename test_jit to test_mjit
to avoid confusion with YJIT
2022-05-20 21:32:55 -07:00
Hiroshi SHIBATA
4146fd284b
Rewrite with assert_ractor for multiple ractor environment 2022-05-20 19:48:28 +09:00
Hiroshi SHIBATA
b6649797ee
Picked the missing test file from 8faba54b2d 2022-05-20 18:53:16 +09:00
Nobuyoshi Nakada
1d9f2a4504
[ruby/racc] Show diffs
0b679e2f69
2022-05-20 17:49:15 +09:00
Andrew Bromwich
a15d0e267a
[flori/json] Fix parser bug for empty string allocation
When `HAVE_RB_ENC_INTERNED_STR` is enabled it is possible to
pass through a null pointer to `rb_enc_interned_str` resulting
in a segfault

Fixes #495

b59368a8c2
2022-05-20 17:49:13 +09:00
Charles Oliver Nutter
a37051ef3b
[flori/json] Remove unknown keyword arg from DateTime.parse
This snuck in while addding tests for the `create_additions`
feature. Caught by JRuby when we added the `limit` option to the
Date/DateTime parsing methods, which causes this to be rejected as
an unknown keyword.

b1007dff66
2022-05-20 17:49:13 +09:00
Hiroshi SHIBATA
aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
Takashi Kokubun
b8a268e293
YJIT: Add opt_succ (#5919) 2022-05-19 11:52:52 -04:00
Benoit Daloze
354cd6f210 [ruby/timeout] Handle Timeout + fork and add test for it
4baee63b9b
2022-05-19 07:19:40 +09:00
Benoit Daloze
89fbec224d [ruby/timeout] Reimplement Timeout.timeout with a single thread and a Queue
2bafc458f1
2022-05-19 07:19:39 +09:00
Samuel Williams
60d45b2ee8
Restore implicit relationship between autoload_const and autoload_data during GC. (#5911) 2022-05-17 19:12:36 +12:00
Samuel Williams
f626998c4f
Delete autoload data from global features after autoload has completed. (#5910)
* Update naming of critical section assertions macros.

* Improved locking for autoload.
2022-05-17 00:50:02 +12:00
Aaron Patterson
ebaf56c013 YJIT: Implement getblockparam
This implements the getblockparam instruction.

There are two cases we need to handle depending on whether or not
VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM is set in the environment flag.

When the modified flag is unset, we need to call rb_vm_bh_to_procval to
get a proc from our passed block, save the proc in the environment, and
set the modified flag.

In the case that the modified flag is set we are able to just use the
existing proc in the environment.

One quirk of this is that we need to call jit_prepare_routine_call early
and ensure we update PC and SP regardless of the branch taken, so that
we have a consistent SP offset at the start of the next instruction.

We considered using a chain guard to generate these two paths
separately, but decided against it because it's very common to see both
and the modified case is basically a subset of the instructions in the
unmodified case.

This includes tests for both getblockparam and getblockparamproxy which
was previously missing a test.
2022-05-12 14:34:18 -07:00
Benoit Daloze
40ca208a6d [ruby/uri] Improve URI.register_scheme tests and automatically upcase the given scheme
* Also add docs and mention current limitations.
* For reference, https://stackoverflow.com/a/3641782/388803 mentions the
  valid characters in schemes.

4346daac75
2022-05-12 18:19:17 +09:00
Jeremy Evans
fbebfe1697 [ruby/uri] Add URI::Generic#decoded_#{user,password}
URI::Generic#{user,password} return the encoded values, which are
not that useful if you want to do authentication with them.
Automatic decoding by default would break backwards compatibility.
Optional automatic decoding via a keyword to URI.parse would
require threading the option through at least 3 other methods, and
would make semantics confusing (user= takes encoded or unencoded
password?) or require more work.  Thus, adding this as a separate
method seemed the simplest approach.

Unfortunately, URI lacks a method for correct decoding.  Unlike in
www form components, + in earlier parts of the URI such as the
userinfo section is treated verbatim and not as an encoded space.
Add URI.#{en,de}code_uri_component methods, which are almost the
same as URI.#{en,de}code_www_form_component, but without the
special SP => + handling.

Implements [Feature #9045]

16cfc4e92f
2022-05-12 14:54:37 +09:00
Noah Gibbs
e88ada4699
Ruby shovel operator (<<) speedup. (#5896)
For string concat, see if compile-time encoding of strings matches.
If so, use simple buffer string concat at runtime. Otherwise, use
encoding-checking string concat.
2022-05-11 11:20:21 -04:00
Nobuyoshi Nakada
d0983af61c
Fix the order of assert_eqaul and remove unused variables 2022-05-10 10:15:27 +09:00
Samuel Williams
cea34bd808
Add basic binary operators (and, or, xor, not) to IO::Buffer. (#5893) 2022-05-09 17:19:01 +12:00
Yusuke Endoh
df0bcb3385 test/fiber/test_scheduler.rb: Remove the test file from $LOADED_FEATURES
to prevent the following failure on `make test-all --repeat-count=2`

http://ci.rvm.jp/results/trunk-repeat20-asserts@phosphorus-docker/3957774
```
  1) Error:
TestFiberScheduler#test_autoload:
NameError: uninitialized constant TestFiberSchedulerAutoload
          Object.const_get(:TestFiberSchedulerAutoload)
                ^^^^^^^^^^
```
2022-05-09 10:20:25 +09:00
Samuel Williams
ef525b012a
Explicit handling of frozen strings in IO::Buffer#for. (#5892) 2022-05-09 11:03:04 +12:00
Samuel Williams
fd6cef79f5
Use a proper mutex for autoloading features. (#5788)
Object#autoload implements a custom per-thread "mutex" for blocking
threads waiting on autoloading a feature. This causes problems when used
with the fiber scheduler. We swap the implementation to use a Ruby mutex
which is fiber aware.
2022-05-08 10:22:58 +12:00