Commit graph

16692 commits

Author SHA1 Message Date
Nobuyoshi Nakada
4b1504ae0a [ruby/uri] Fix splitting relative URI
ffbab83de6
2022-10-13 16:24:53 +09:00
Samuel Williams
765ee822b5
Add missing f.resume to fiber test. (#6539) 2022-10-13 19:04:06 +13:00
NARUSE, Yui
dd5118f852
URI.parse should set empty string in host instead of nil 2022-10-13 11:04:06 +09:00
Yusuke Endoh
504e388525 Suppress a "warning: method redefined" in test/ruby/test_method.rb 2022-10-12 21:51:23 +09:00
Yusuke Endoh
9cfc45d6e5 Suppress warnings in test/ruby/test_ast.rb
The tests for error tolerance printed some warnings. This change
suppresses them.
2022-10-12 21:48:28 +09:00
Samuel Williams
04d291a490
Simplify implementation of scheduler io_read and io_write. (#6527) 2022-10-12 15:56:35 +13:00
Kazuki Yamaguchi
4e29ca0c40
Add :ssl_min_version and :ssl_max_version options
Replace :ssl_version option with these two new options. These provide
access to OpenSSL::SSL::SSLContext#{min,max}_version=, which is the
recommended way to specify SSL/TLS protocol versions.
2022-10-12 10:36:51 +09:00
Samuel Williams
ced1d17280
Improvements to IO::Buffer implementation and documentation. (#6525) 2022-10-12 12:59:05 +13:00
Jemma Issroff
913979bede
Make inline cache reads / writes atomic with object shapes
Prior to this commit, we were reading and writing ivar index and
shape ID in inline caches in two separate instructions when
getting and setting ivars. This meant there was a race condition
with ractors and these caches where one ractor could change
a value in the cache while another was still reading from it.

This commit instead reads and writes shape ID and ivar index to
inline caches atomically so there is no longer a race condition.

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-10-11 08:40:56 -07:00
Jemma Issroff
ad63b668e2
Revert "Revert "This commit implements the Object Shapes technique in CRuby.""
This reverts commit 9a6803c90b.
2022-10-11 08:40:56 -07:00
dependabot[bot]
5ffbb2be18 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.30 to 0.9.31.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.30...v0.9.31)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

4ad57bacea
2022-10-11 21:29:13 +09:00
dependabot[bot]
ccf61c01d5 [rubygems/rubygems] Bump rb-sys in /test/rubygems/test_gem_ext_cargo_builder/custom_name
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.30 to 0.9.31.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.30...v0.9.31)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

476490d529
2022-10-11 21:29:01 +09:00
Samuel Williams
1bafa4a59b
Ignore failure to set nonblock mode. (#6524) 2022-10-11 10:18:20 +13:00
Vladimir Dementyev
4954c9fc0f Add MatchData#deconstruct/deconstruct_keys 2022-10-10 12:41:13 +09:00
Nobuyoshi Nakada
546566d34b
Do not set $! to SyntaxError when error tolerant 2022-10-09 19:07:21 +09:00
Nobuyoshi Nakada
d9e2ef6000 Extract assert_error_tolerant 2022-10-09 19:05:31 +09:00
Nobuyoshi Nakada
f178ff3933
Allow abbreviated dump options with additional options 2022-10-09 16:27:34 +09:00
Nobuyoshi Nakada
43f692248e
Set AST prettyprint width to 80 explicitly
`PrettyPrint` results depend on the `COLUMNS` environment variable by
default.
2022-10-09 16:26:18 +09:00
Peter Zhu
b22a2803a8 Fix flaky test test_thrashing_for_young_objects
The test could be flaky when a heap has below GC_HEAP_INIT_SLOTS number
of free slots because it would trigger a major GC and allocate more
pages.
2022-10-08 15:06:30 -04:00
Maciek Rząsa
0f231f2bab [ruby/optparse] Don't treat empty string as an option description
078638ee6d
2022-10-08 19:30:34 +09:00
yui-knk
3531086095 "expr_value" can be error
So that "IF" node is kept in the case below

```
def m
  if
end
```

[Feature #19013]
2022-10-08 17:59:11 +09:00
yui-knk
4bfdf6d06d Move error from top_stmts and top_stmt to stmt
By this change, syntax error is recovered smaller units.
In the case below, "DEFN :bar" is same level with "CLASS :Foo"
now.

```
module Z
  class Foo
    foo.
  end

  def bar
  end
end
```

[Feature #19013]
2022-10-08 17:59:11 +09:00
yui-knk
4f24f3ea94 Treat "end" as reserved word with consideration of indent
"end" after "." or "::" is treated as local variable or method,
see `EXPR_DOT_bit` for detail.
However this "changes" where `bar` method is defined. In the example
below it is not module Z but class Foo.

```
module Z
  class Foo
    foo.
  end

  def bar
  end
end
```

[Feature #19013]
2022-10-08 17:59:11 +09:00
yui-knk
342d4c16d9 Generates "end" tokens if parser hits end of input
but "end" tokens are needed for correct language.

[Feature #19013]
2022-10-08 17:59:11 +09:00
yui-knk
fbbdbdd891 Add error_tolerant option to RubyVM::AST
If this option is enabled, SyntaxError is not raised and Node is
returned even if passed script is broken.

[Feature #19013]
2022-10-08 17:59:11 +09:00
st0012
5b3079a8a5 [ruby/irb] Sort constant completion's candidates
ee9b33c817
2022-10-08 03:17:42 +09:00
st0012
7be5e9b971 [ruby/irb] Correct assert_equal's usage in completion tests
https://test-unit.github.io/test-unit/en/Test/Unit/Assertions.html#assert_equal-instance_method

00f90d40ad
2022-10-08 03:17:41 +09:00
st0012
afc1f4fba4 [ruby/irb] Add constant completion test
39f8fcb058
2022-10-08 03:17:40 +09:00
st0012
3e18bb916f [ruby/irb] Regroup completion tests
71631287c8
2022-10-08 03:17:39 +09:00
st0012
83a9b91522 [ruby/irb] Add tests for primitive types' method completion
2e12fac38e
2022-10-08 03:17:38 +09:00
Peter Zhu
ad0def7f25 Add more debugging output to test_thrashing_for_young_objects 2022-10-07 09:39:07 -04:00
Samuel Williams
e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Hiroshi SHIBATA
4f78560cf1
Add --with-libffi-source-dir feature and removed --enable-bundled-libffi option. (#113)
https://bugs.ruby-lang.org/issues/18571

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07 15:20:11 +09:00
Sutou Kouhei
92f0c53934 [ruby/fiddle] test: don't use assert_true/assert_false
GitHub: GH-102

They aren't available in ruby/ruby.

ced671e43b
2022-10-07 15:18:54 +09:00
Sutou Kouhei
9f62768e51 [ruby/fiddle] test: ensure freeing closure
GitHub: GH-102

b2fef1770d
2022-10-07 15:18:53 +09:00
Sutou Kouhei
824c474c95 [ruby/fiddle] test: ensure freeing closure
GitHub: GH-102

This also improves freed closures assertions.

0495624caf
2022-10-07 15:18:53 +09:00
Sutou Kouhei
dfca6a8799 [ruby/fiddle] test: don't use power-assert
It seems that we can't use it in ruby/ruby.

e1221297fb
2022-10-07 15:18:52 +09:00
Sutou Kouhei
7c33141293 [ruby/fiddle] test: ensure freeing closure
GitHub: GH-102

This also improves freed closures assertions.

f6431f3cf8
2022-10-07 15:18:52 +09:00
Sutou Kouhei
255e617bc3 [ruby/fiddle] Add Fiddle::Closure.create and Fiddle::Closure.free
GitHub: fix GH-102

It's for freeing a closure explicitly.

We can't use Fiddle::Closure before we fork the process. If we do it,
the process may be crashed with SELinux.

See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091
for details.

Reported by Vít Ondruch. Thanks!!!

a0ccc6bb1b
2022-10-07 15:18:51 +09:00
Sutou Kouhei
191b91f47a [ruby/fiddle] test: suppress a warning
test/fiddle/test_import.rb:138: warning:
    ambiguous first argument; put parentheses or a space even after `-' operator

060eef76ad
2022-10-07 15:18:51 +09:00
Aaron Patterson
0097c7f388 [ruby/fiddle] Add sym_defined? methods to test if a symbol is defined (https://github.com/ruby/fiddle/pull/108)
I would like to check if a symbol is defined before trying to access it.
Some symbols aren't available on all platforms, so instead of raising an
exception, I want to check if it's defined first.

Today we have to do:

```ruby
begin
  addr = Fiddle::Handle.sym("something")
  # do something
rescue Fiddle::DLError
end
```

I want to write this:

```ruby
if Fiddle::Handle.sym_defined?("something")
  addr = Fiddle::Handle.sym("something")
  # do something
end
```

9d3371de13

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07 15:18:51 +09:00
Aaron Patterson
755d99e878 [ruby/fiddle] Move "type" constants to Fiddle::Types (https://github.com/ruby/fiddle/pull/112)
This helps to reduce repetition in code. Instead of doing "TYPE_*"
everywhere, you can do `include Fiddle::Types`, and write the type name
directly.

This PR is to help reduce repetition when writing Fiddle code. Right now
we have to type `TYPE_` everywhere, and you also have to include all of
`Fiddle` to access `TYPE_*` constants. With this change, you can just
include `Fiddle::Types` and it will shorten your code and also you only
have to include those constants.

Here is an example before:

```ruby
require "fiddle"

module MMAP
  # All Fiddle constants included
  include Fiddle

  def self.make_function name, args, ret
    ptr = Handle::DEFAULT[name]
    func = Function.new ptr, args, ret, name: name
    define_singleton_method name, &func.to_proc
  end

  make_function "munmap", [TYPE_VOIDP, # addr
                           TYPE_SIZE_T], # len
                           TYPE_INT

  make_function "mmap", [TYPE_VOIDP,
                         TYPE_SIZE_T,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT], TYPE_VOIDP

  make_function "mprotect", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT], TYPE_INT
end
```

After:

```ruby
require "fiddle"

module MMAP
  # Only type names included
  include Fiddle::Types

  def self.make_function name, args, ret
    ptr = Fiddle::Handle::DEFAULT[name]
    func = Fiddle::Function.new ptr, args, ret, name: name
    define_singleton_method name, &func.to_proc
  end

  make_function "munmap", [VOIDP, # addr
                           SIZE_T], # len
                           INT

  make_function "mmap", [VOIDP, SIZE_T, INT, INT, INT, INT], VOIDP

  make_function "mprotect", [VOIDP, SIZE_T, INT], INT
end
```

We only need to import the type names, and you don't have to type
`TYPE_` over and over. I think this makes Fiddle code easier to read.

49fa7233e5

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07 15:18:50 +09:00
Aaron Patterson
48a6498406 [ruby/fiddle] Add constants for unsigned values (https://github.com/ruby/fiddle/pull/111)
This commit adds constants for unsigned values. Currently we can use `-`
to mean "unsigned", but I think having a specific name makes Fiddle more
user friendly. This commit continues to support `-`, but introduces
negative constants with "unsigned" names

I think this will help to eliminate [this
code](3a56bf0bcc/lib/mjit/c_type.rb (L31-L38))

2bef0f1082

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07 15:18:49 +09:00
Sutou Kouhei
6d01b66764 [ruby/fiddle] test: ensure GC-ing closures
GitHub: fix GH-102

We can't use Fiddle::Closure before we fork the process. If we do it,
the process may be crashed with SELinux.

See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091
for details.

Reported by Vít Ondruch. Thanks!!!

1343ac7a95
2022-10-07 15:18:49 +09:00
Nobuyoshi Nakada
1b7c5c394f [ruby/date] Fix misplaced time zone offset checks
d21c69450a
2022-10-07 14:41:31 +09:00
Nobuyoshi Nakada
a87de5e3c1 [ruby/rdoc] Special characters are prohibited as filename on Windows
13b9da5932
2022-10-07 12:12:10 +09:00
Nobuyoshi Nakada
a3cb09c7d1 [ruby/rdoc] Escape file names
https://hackerone.com/reports/1321358

8c07cc4657
2022-10-07 12:12:08 +09:00
Nobuyoshi Nakada
8d0b2162a0 [ruby/rdoc] Escape main title
https://hackerone.com/reports/1187156

5dedb5741d
2022-10-07 12:09:23 +09:00
Nobuyoshi Nakada
586e18b946 [ruby/rdoc] Escape HYPERLINKs
ac35485be6
2022-10-07 12:09:22 +09:00
Nobuyoshi Nakada
9e3ab9da7f [ruby/rdoc] Escape RDOCLINKs
https://hackerone.com/reports/1187156

7cecf1efae
2022-10-07 12:09:21 +09:00