Commit graph

67695 commits

Author SHA1 Message Date
Kazuki Yamaguchi
595644e4f6 [ruby/openssl] pkey: fix interrupt handling in OpenSSL::PKey.generate_key
rb_thread_call_without_gvl() can be interrupted, but it may be able to
resume the operation. Call rb_thread_check_ints() to see if it raises
an exception or not.

88b90fb856
2021-07-18 17:44:46 +09:00
Kazuki Yamaguchi
8cfe92b8a2 [ruby/openssl] pkey: allow setting algorithm-specific options in #sign and #verify
Similarly to OpenSSL::PKey.generate_key and .generate_parameters, let
OpenSSL::PKey::PKey#sign and #verify take an optional parameter for
specifying control strings for EVP_PKEY_CTX_ctrl_str().

faf85d7c1d
2021-07-18 17:44:46 +09:00
Kazuki Yamaguchi
e2014d0354 [ruby/openssl] pkey: prepare pkey_ctx_apply_options() for usage by other operations
The routine to apply Hash to EVP_PKEY_CTX_ctrl_str() is currently used
by key generation, but it is useful for other operations too. Let's
change it to a slightly more generic name.

b2b77527fd
2021-07-18 17:44:45 +09:00
Kazuki Yamaguchi
1706302be5 [ruby/openssl] pkey: fix potential memory leak in PKey#sign
Fix potential leak of EVP_MD_CTX object in an error path. This path is
normally unreachable, since the size of a signature generated by any
supported algorithms would not be larger than LONG_MAX.

99e8630518
2021-07-18 17:44:44 +09:00
Kazuki Yamaguchi
b7a908af34 [ruby/openssl] ossl.c: do not set locking callbacks on LibreSSL
Similarly to OpenSSL >= 1.1.0, LibreSSL 2.9.0 ensures thread safety
without requiring applications to set locking callbacks and made
related functions no-op.

7276233e1a
2021-07-18 17:44:43 +09:00
Kazuki Yamaguchi
88d64418dd [ruby/openssl] ssl: use TLS_method() instead of SSLv23_method() for LibreSSL
LibreSSL 2.2.2 introduced TLS_method(), but with different semantics
from OpenSSL: TLS_method() enabled TLS >= 1.0 while SSLv23_method()
enabled all available versions, which included SSL 3.0 in addition.

However, LibreSSL 2.3.0 removed SSL 3.0 support completely and now
TLS_method() and SSLv23_method() are equivalent.

3b7d7045b8
2021-07-18 17:44:43 +09:00
Kazuki Yamaguchi
50332c4071 [ruby/openssl] ssl: call SSL_CTX_set_ecdh_auto() on OpenSSL 1.0.2 only
SSL_CTX_set_ecdh_auto() exists in OpenSSL 1.1.0 and LibreSSL 2.6.1, but
it is made no-op and the automatic curve selection cannot be disabled.
Wrap it with ifdef to make it clear that it is safe to remove it
completely when we drop support for OpenSSL 1.0.2.

2ae8f21234
2021-07-18 17:44:42 +09:00
Kazuki Yamaguchi
cd002305f0 [ruby/openssl] require OpenSSL >= 1.0.2 and LibreSSL >= 3.1
Clean up old version guards in preparation for the upcoming OpenSSL 3.0
support.

OpenSSL 1.0.1 reached its EOL on 2016-12-31. At that time, we decided
to keep 1.0.1 support because many major Linux distributions were still
shipped with 1.0.1. Now, nearly 4 years later, most Linux distributions
are reaching their EOL and it should be safe to assume nobody uses them
anymore. Major ones that were using 1.0.1:

 - Ubuntu 14.04 is EOL since 2019-04-30
 - RHEL 6 will reach EOL on 2020-11-30

LibreSSL 3.0 and older versions are no longer supported by the LibreSSL
team as of October 2020.

Note that OpenSSL 1.0.2 also reached EOL on 2019-12-31 and 1.1.0 also
did on 2018-08-31.

c055938f4b
2021-07-18 17:44:41 +09:00
Kazuki Yamaguchi
decce40da7 [ruby/openssl] bn: update documentation of OpenSSL::BN#initialize and #to_s
Clarify that BN.new(str, 2) and bn.to_s(2) handles binary string in
big-endian, and the sign of the bignum is ignored.

Reference: https://github.com/ruby/openssl/issues/431

6fae2bd612
2021-07-18 17:44:40 +09:00
Rick Mark
01fcb8f45b [ruby/openssl] BN.abs and BN uplus
Adds standard math abs fuction and revises uplus to return a duplicated object due to BN mutability

0321b1e945
2021-07-18 17:44:39 +09:00
git
ed1e5663a4 * 2021-07-18 [ci skip] 2021-07-18 12:40:58 +09:00
Nobuyoshi Nakada
e0e12202c7
Use rb_block_call() instead of the deprecated rb_iterate() 2021-07-18 11:40:21 +09:00
Kazuki Yamaguchi
4885c44bca cont.c: fix formatting of RDoc for Fiber class 2021-07-17 13:37:41 +09:00
Kazuhiro NISHIYAMA
f11f9fc921
Disable spec of pattern matching is experimental since 3.1 2021-07-17 13:24:23 +09:00
Kazuhiro NISHIYAMA
2a5b5ff49a
Fix a spec failure
```
1)
Warning.[]= :experimental emits and suppresses warnings for :experimental FAILED
Expected "" =~ /is experimental/
to be truthy but was nil
```
2021-07-17 13:24:08 +09:00
Kazuhiro NISHIYAMA
503fa1620c
Fix a spec failure
```
1)
The -W command line option with :no-experimental suppresses experimental warnings FAILED
Expected "" =~ /is experimental/
to be truthy but was nil
```
2021-07-17 13:16:48 +09:00
git
f36a5a7624 * 2021-07-17 [ci skip] 2021-07-17 11:16:40 +09:00
Kazuki Tsujimoto
eed5e8f796
One-line pattern matching is no longer experimental
https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20210715Japan.md#feature-17724-make-the-pin-operator-support-instanceclassglobal-variables-jeremyevans0
2021-07-17 11:13:52 +09:00
Benoit Daloze
fd0df9c4fb Emit deprecatation warnings for rb_iterate()
* It is obsolete since 1.9, see
  https://github.com/ruby/ruby/blob/master/doc/extension.rdoc#label-Control+Structure
  and [Misc #18025]
2021-07-16 12:11:24 +02:00
Nobuyoshi Nakada
301d194ee3 Add Integer.try_convert [Feature #15211] 2021-07-16 17:49:53 +09:00
Yusuke Endoh
eee709595c io.c: Clarify the behavior of IO.read when called as File.read
Ditto to `IO.binread`, `IO.write`, `IO.binwrite`, `IO.foreach`, and
`IO.readlines`.
2021-07-16 16:10:54 +09:00
Masafumi Koba
650a65c6fc
[rubygems/rubygems] Add missing require 'fileutils' in Gem::ConfigFile
c4004fadd9
2021-07-16 15:40:08 +09:00
David Rodríguez
71d3c9bbfa
[rubygems/rubygems] Fix bundle plugin install --help showing bundle install's help
b7b7d16aa8
2021-07-16 15:40:08 +09:00
Andre Arko
c5f78ade5a
[rubygems/rubygems] fix dangling empty hooks
it turns out that running `bundle plugin uninstall some-plugin` would remove that plugin from the list of hooks, but if the list of hooks for an event was now empty, we would serialize the empty array into yaml as an empty single bullet item. which would then get unserialized as a plugin with the name empty string. which we would then try to load and explode. 😬

545ebba9a5
2021-07-16 15:40:08 +09:00
Andre Arko
a3d2200b2a
[rubygems/rubygems] test loading bad plugins with nil/empty names
e64b1f3497
2021-07-16 15:40:07 +09:00
Andre Arko
5cce96891e
[rubygems/rubygems] remove focus
584a393812
2021-07-16 15:40:07 +09:00
Andre Arko
44ba77d16d
[rubygems/rubygems] lock for development on macos
60469e4cac
2021-07-16 15:40:07 +09:00
David Rodríguez
227c2deff4
[rubygems/rubygems] Fix development gem unintentionally removed on an edge case
When a development dependency was duplicated inside the gemspec and
Gemfile with the same requirements, we went from printing a warning to
removing the gem altogether.

This change makes it not print a warning, but don't remove the gem
either.

8bb2488131
2021-07-16 15:40:07 +09:00
Jared Beck
bbaebbf529
[rubygems/rubygems] Fix contradictory message about deletion of default gem
[Fixes #4733]

fce7f3eb7d
2021-07-16 15:40:07 +09:00
Nobuyoshi Nakada
29ed9d1aaa [ruby/error_highlight] Fix leaked tempfiles
8b353a10a7
2021-07-16 15:25:13 +09:00
Samuel Williams
6073a8bdc0 Add debug assertion in rb_funcall* that the current thread has the gvl. 2021-07-16 17:32:02 +12:00
Hiroshi SHIBATA
55a79b648c
Adjust the release version of ruby2_keywords 2021-07-16 13:50:15 +09:00
Nobuyoshi Nakada
25689024cf
Added code fence to the example in [Feature #17724] [ci skip] 2021-07-16 11:26:30 +09:00
Jeremy Evans
95f8ffa5f6
Copy hash compare_by_identity setting in more cases
This makes the compare_by_identity setting always copied
for the following methods:

* except
* merge
* reject
* select
* slice
* transform_values

Some of these methods did not copy the setting, or only
copied the setting if the receiver was not empty.

Fixes [Bug #17757]

Co-authored-by: Kenichi Kamiya <kachick1@gmail.com>
2021-07-15 10:04:17 -07:00
Jeremy Evans
fa87f72e1e Add pattern matching pin support for instance/class/global variables
Pin matching for local variables and constants is already supported,
and it is fairly simple to add support for these variable types.

Note that pin matching for method calls is still not supported
without wrapping in parentheses (pin expressions).  I think that's
for the best as method calls are far more complex (arguments/blocks).

Implements [Feature #17724]
2021-07-15 09:56:02 -07:00
aycabta
f1035248af [ruby/irb] Show code page by irb_info on Windows
6160d74199
2021-07-16 01:55:25 +09:00
aycabta
456d0019dd [ruby/irb] Escape space in free-spacing mode
085ac42947
2021-07-16 01:55:16 +09:00
git
feec80a362 * 2021-07-16 [ci skip] 2021-07-16 00:49:08 +09:00
Peter Zhu
e5fe48646c [Bug #18014] Add assertion to verify freelist
This commit adds an assertion has been added after `gc_page_sweep` to
verify that the freelist length is equal to the number of free slots in
the page.
2021-07-15 11:48:52 -04:00
Peter Zhu
4a627dbdfd [Bug #18014] Fix memory leak in GC when using Ractors
When a Ractor is removed, the freelist in the Ractor cache is not
returned to the GC, leaving the freelist permanently lost. This commit
recycles the freelist when the Ractor is destroyed, preventing a memory
leak from occurring.
2021-07-15 11:48:52 -04:00
Peter Zhu
119697f61e [Bug #18014] Fix rb_gc_force_recycle unmark before sweep
If we force recycle an object before the page is swept, we should clear
it in the mark bitmap. If we don't clear it in the bitmap, then during
sweeping we won't account for this free slot so the `free_slots` count
of the page will be incorrect.
2021-07-15 11:48:52 -04:00
Nobuyoshi Nakada
3e7a7fb28a
Make Struct#keyword_init? return nil by default [Feature #18008] 2021-07-15 22:24:02 +09:00
Nobuyoshi Nakada
33bea3bdff
Regularize keyword_init values not to hold the argument object 2021-07-15 21:32:04 +09:00
NARUSE, Yui
835c63cd88 Add tests and NEWS [Feature #18008] 2021-07-15 18:21:49 +09:00
hkdnet
1a63754416
struct.c: Add keyword_init? singleton method for StructClass (#4609)
Fixes [Feature #18008]
2021-07-15 18:14:27 +09:00
卜部昌平
3ce2bf4d90 rb_interned_id_p: does not exist
This declaration was added at commit 0ee5a49dd4
without its implementation.  Must be a mistake.

Note also that we ended up having this exct same functionality
implemented under a name of rb_check_id().
2021-07-15 16:54:59 +09:00
卜部昌平
2d9aacf644 rb_enc_casefold: does not exist
This declaration was added at commit 0ee5a49dd4
without its implementation.  Must be a mistake.
2021-07-15 16:54:59 +09:00
Yusuke Endoh
645616c273 process.c: Call rb_thread_atfork in rb_fork_ruby
All occurrences of rb_fork_ruby are followed by a call rb_thread_fork in
the created child process.

This is refactoring and a potential preparation for [Feature #17795].
(rb_fork_ruby may be wrapped by Process._fork_.)
2021-07-15 16:46:08 +09:00
Patrik Ragnarsson
8f62f12c35 Fix typo in flag in NEWS.md 2021-07-15 16:16:51 +09:00
Nobuyoshi Nakada
f347b586fb
[ruby/fiddle] Handle#file_name results in very platform dependent 2021-07-15 09:49:56 +09:00