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

58392 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Evans 978276a7d9 Update documentation for File#{readable,writable,executable}{,_real}? [ci skip]
Some OS-level security features cause these methods to not return
expected results.  For example fs.protected_regular sysctl on Linux,
or pledge(2)/unveil(2) on OpenBSD.

Fixes [Bug #16002]
2019-10-14 17:43:11 -07:00
Masatoshi SEKI c3a6260302 add require "monitor" 2019-10-14 22:56:37 +09:00
Masatoshi SEKI 8488d5b5b6 Automatically close fds on fork (and GC). The connection pools are maintained at thread scope. 2019-10-14 20:30:22 +09:00
Florian Frank a4cf11c10f
[flori/json] fix test as reported in #343
https://github.com/flori/json/commit/565c72ba9e
2019-10-14 19:54:49 +09:00
Sho Hashimoto 308bbb4e10
[flori/json] Add ascii_only option to JSON::Ext::Generator::State.new.
https://github.com/flori/json/commit/0e99a9aac5
2019-10-14 19:54:49 +09:00
Watson 98a9445db9
[flori/json] Add shortcut converting to String
In where to convert Hash key to String for json, this patch will add shortcut for String/Symbol in Hash key.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    "id" => i,
    :age => 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/38c0f6dbe4
2019-10-14 19:54:49 +09:00
Watson a2f9c38a71
[flori/json] Convert Hash object using rb_hash_foreach()
To convert Hash convert, this part was using following pseudo code

```
obj.keys.each do |key|
  value = obj[key]
  ...
end
```

and `rb_funcall()` was called for `obj.keys`.
It might be slightly heavy to call the Ruby method.
This patch will iterate to convert Hash object about key/value using `rb_hash_foreach()` Ruby API instead of `rb_funcall()`.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    55.000  i/100ms
Calculating -------------------------------------
                json    558.501  (± 1.1%) i/s -      2.805k in   5.022986s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    "id" => i,
    :age => 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/a73323dc5e
2019-10-14 19:54:49 +09:00
Nobuyoshi Nakada 2003755a2c
[flori/json] Fixed unexpected illegal/malformed utf-8 error
flori/json@c34d01ff6a does not
consider US-ASCII compatible but non-UTF-8 encodings, and causes
an error in RDoc tests.

https://github.com/flori/json/commit/4f471bf590
2019-10-14 19:54:48 +09:00
Watson d7fa7e2c86
[flori/json] Convert string encoding to UTF-8 only when needed
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   189.000  i/100ms
Calculating -------------------------------------
                json      1.964k (± 3.3%) i/s -      9.828k in   5.011237s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    "id" => i,
    :age => 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/c34d01ff6a
2019-10-14 19:54:48 +09:00
Watson 40724d7d10
[flori/json] Convert String encoding using `rb_str_encode()`
`rb_funcall` might be slightly heavy to call the Ruby method.
This patch will convert String encoding using `rb_str_encode()` instead of `rb_funcall()`.

## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    "id" => i,
    :age => 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/9ae6d2969c
2019-10-14 19:54:48 +09:00
Watson 641136c4af
[flori/json] Does not check whether illegal utf-8 if string has ascii only.
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    25.000  i/100ms
Calculating -------------------------------------
                json    250.478  (± 4.8%) i/s -      1.250k in   5.002238s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    32.000  i/100ms
Calculating -------------------------------------
                json    360.652  (± 3.6%) i/s -      1.824k in   5.064511s
```

## Test code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj << {
    :string => "x" * 100,
    :utf8 => "あ" * 100
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count < iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```

https://github.com/flori/json/commit/91a24ecac3
2019-10-14 19:54:48 +09:00
Sho Hashimoto d9e50fcbeb
[flori/json] Pass args all #to_json in json/add/*.
https://github.com/flori/json/commit/36a7ef6790
2019-10-14 19:54:48 +09:00
Florian Frank 7376d70cb0
[flori/json] Only attempt to resize strings not other objects
https://github.com/flori/json/commit/167ada8da7
2019-10-14 19:54:48 +09:00
Kazuhiro NISHIYAMA ede1a3dc11
Fix typos [ci skip] 2019-10-14 17:30:04 +09:00
Nobuyoshi Nakada 0195966ba2
Suppress warnings for Thread.exclusive 2019-10-14 15:42:27 +09:00
Nobuyoshi Nakada 3e763883ea
Fixed overflow at onig_region_set
To get rid of a bug of `onig_region_set` which takes `int`s
instead of `OnigPosition`s, set elements of `beg` and `end`
members directly, for the time being.
2019-10-14 15:10:56 +09:00
Jeremy Evans d0ed935d5b Fix some DRb issues (#2552)
* Handle BasicObject in drb

Also fix a bug in rescue clause of any_to_s because sprintf
does not handle the %l modifier.

Fixes [Bug #7833]

* Do not send a reply to the client if there is a connection error

This allows for normal TCP shutdown (fin-ack-fin-ack instead of
fin-ack-push-rst).

Patch from pierre@mouraf.org (Pierre-Alexandre Meyer).

Fixes [Bug #2339]

* Detect fork and do not reuse forked connections in drb

This associates each DRbConn with a pid, and if the pid changes,
it closes any DRbConns in the pool with a pid that no longer
matches.  This fixes DRb servers from sending messages intended
for one client to another client after forking.

Fixes [Bug #2718]
Fixes [Bug #14471]
2019-10-14 14:20:32 +09:00
Sutou Kouhei 95c420c4a6
Import StringScanner 1.0.3 (#2553) 2019-10-14 12:40:50 +09:00
Takashi Kokubun 6fa3492362
Eliminate the possibility to leave freed ISeq
in active_units

Hoping to fix:
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/2311375
2019-10-13 19:31:18 -07:00
Takashi Kokubun 183b421509
Delay the free until we stop referring to a unit
`if (unit->iseq)` might have referred to a freed unit. Therefore this
commit delays its free.
2019-10-13 14:15:14 -07:00
git 673f3842dd * 2019-10-14 [ci skip] 2019-10-14 02:05:30 +09:00
Takashi Kokubun 26fae9aa9d
Remove the quick stop path after convert_unit_to_func
Now I'm not exactly sure why I needed to check `stop_worker_p` after
`mjit_copy_cache_from_main_thread` of `convert_unit_to_func`
in 4161674b2f.
If it's for avoiding deadlock under `in_gc` condition, we should keep it.

However, if it's not the case and it's just for retrying accidental
compilation failure or just to avoid `MJIT_ATOMIC_SET` and
`compact_all_jit_code`, I think this quick stop path is not mandatory.

Because this path is somewhat problematic in my upcoming fix in
mjit_worker, let me try to remove this first and see how CI goes.
2019-10-13 09:59:44 -07:00
Burdette Lamar 6a1809e2e1 Enhance doc for ENV.delete 2019-10-13 09:48:20 +09:00
git 6ee2fb5021 * 2019-10-13 [ci skip] 2019-10-13 00:54:04 +09:00
Yusuke Endoh a5ecf7e0a1 dir.c (join_path_from_pattern): check NULL from malloc
Coverity Scan points out that all the return values of GLOB_ALLOC_N are
NULL-checked except this call.
2019-10-13 00:51:50 +09:00
Yusuke Endoh 90b9900dc1 io.c (rb_update_max_fd): fail with a negative file descripter
Coverity Scan points out that ext/socket/unixsocket.c may pass -1 to
rb_update_max_fd.  I'm unsure whether it can happen actually or not, but
it would be good for the function to reject a negative value.
2019-10-13 00:49:18 +09:00
Yusuke Endoh ebc2198d9f re.c (match_set_string): add a check for memory allocation
Found by Coverity Scan
2019-10-12 22:44:23 +09:00
Nobuyoshi Nakada 7ebf9da788
Also moved fallback definition of __has_attribute 2019-10-12 22:09:49 +09:00
Yusuke Endoh cb14c4a535 missing/setproctitle.c: remove nonsense NULL check
If fmt is NULL, ptitle is uninitialized and used.
SETPROCTITLE(3bsd) says "If fmt is NULL, the process title is restored",
but looks like the feature is not implemented in missing/setproctitle.c.
At least the source code of ruby does not pass NULL to the function.
So I assume this function requires non-NULL fmt.

This issue was found by Coverity Scan.
2019-10-12 21:14:20 +09:00
Nobuyoshi Nakada f405564711
Suppress deprecation warnings of MD5 from Xcode 11.1 2019-10-12 18:47:06 +09:00
Nobuyoshi Nakada 04333da7be
Suppress "clobbered" warnings by gcc 9.2.0 2019-10-12 18:14:15 +09:00
Nobuyoshi Nakada 710bc00379
Moved RB_METHOD_DEFINITION_DECL to intern.h
This macro is used here before defined in ruby.h.
2019-10-12 17:47:28 +09:00
Nobuyoshi Nakada 6333020fc9
atime may not updated unless strictatime is set on macOS Catalina
Cited from mount(8):

```
strictatime
        Always update the file access time when reading from a
        file. Without this option the filesystem may default to a
        less strict update mode, where some access time updates
        are skipped for performance reasons. This option could be
        ignored if it is not supported by the filesystem.
```
2019-10-12 14:58:55 +09:00
Sutou Kouhei 92df7d98b6
Import CSV 3.1.2 (#2547) 2019-10-12 14:03:21 +09:00
Kazuhiro NISHIYAMA d6e68bb263
Use `warn` with `uplevel:` instead of `caller` 2019-10-12 13:25:52 +09:00
git f6a666a1fc * 2019-10-12 [ci skip] 2019-10-12 12:07:36 +09:00
Sutou Kouhei 412cd56766
Import REXML 3.2.3 (#2548) 2019-10-12 12:07:15 +09:00
Yusuke Endoh c866663784 io.c (NUM2IOCTLREQ): Accept a value more than INT_MAX
ioctl accepts int as request arguments on some platforms, but some
requests are more than INT_MAX, e.g., RNDGETENTCNT(0x80045200).
Passing (0x80045200 | (-1 << 32)) may work around the issue, but it may
not work on a platform where ioctl accepts unsigned long.  So this
change uses NUM2LONG and then casts it to int.
2019-10-11 21:43:18 +09:00
Yusuke Endoh 9e4a53fe13 test/ruby/test_rubyoptions.rb (test_encoding): skipped on Android
On Android, nl_langinfo() always returns UTF-8 even when LANG is C.
2019-10-11 21:39:21 +09:00
Yusuke Endoh f3c4e620ac test/test_syslog.rb (test_log): skipped on Android
On Android 28, LOG_PERROR is defined, but not implemented yet.
This change skips Syslog#log explicitly.
2019-10-11 21:13:52 +09:00
Kazuhiro NISHIYAMA d6c80876b7
Use `bind_call` instead of `bind` and `call` 2019-10-11 13:50:27 +09:00
Gabriel Nagy ddfb306e8e win32.c: Remove unused calls to StartSockets (#2312)
NtSocketsInitialized behavior changed in e33b1690, requiring
a call to rb_w32_sysinit for starting Windows Sockets.

This commit removes NtSocketsInitialized entirely to avoid confusion.

Signed-off-by: Gabriel Nagy <gabriel.nagy@puppet.com>
2019-10-11 13:48:02 +09:00
ksss 7cc1cd3d1e Module#define_method: Add UnboundMethod to expected classes 2019-10-11 11:20:11 +09:00
Lourens Naudé 9c24ce551d Reduce the minimum string buffer size from 127 to 63 bytes 2019-10-11 11:16:16 +09:00
Lourens Naudé 0ca4f74967 Right size the numtable in insn_make_insn_table to VM_INSTRUCTION_SIZE 2019-10-11 11:15:43 +09:00
takkanm 87958520f3 set real path to __FILE__ and __dir__ in Binding#irb
When reading Binding#irb, the file of the calling source is reflected in __FILE__ and __dir__.
2019-10-11 09:33:25 +09:00
Jeremy Evans 29c1e9a0d4 Document the difference between expressions and statements [ci skip]
In the grammar, all expressions are statements, but not all
statements are expressions.  Some parts of the grammar accept
expressions and not other types of statements, which causes
similar looking code to parse differently due to operator
precedence.

Mostly from Dan0042 (Daniel DeLorme).

Fixes [Bug #16092]
2019-10-10 13:45:19 -07:00
git ddb0267e76 * 2019-10-11 [ci skip] 2019-10-11 05:15:28 +09:00
Jeremy Evans 2322c94dd6 Support delegates for BasicObject
For BasicObject, bind the Kernel respond_to? instance method to the
object and call it instead of calling the method directly.

Also, use bind_call(recv, ...) for better performance.

Fixes [Bug #16127]
2019-10-10 13:15:00 -07:00
Yusuke Endoh 4171909695 mjit_worker.c: Add `-lm` to the C compiler in MJIT on Android
To avoid:

    cannot locate symbol "modf" referenced by .../_ruby_mjit_XXX.so"
2019-10-10 23:22:37 +09:00