Commit graph

9854 commits

Author SHA1 Message Date
Hiroshi SHIBATA
e3ba5207b5 Removed parser.rl from ext/json/parser/depend 2025-01-20 16:09:00 +09:00
Jean Boussier
df8f93848e [ruby/json] json_string_unescape: use memchr to search for backslashes
5e6cfcf724
2025-01-20 16:09:00 +09:00
Jean Boussier
ba8f22c040 [ruby/json] Cleanup json_decode_float
Move all the decimal_class option parsing in the constructor.

e9adefdc38
2025-01-20 16:09:00 +09:00
Jean Boussier
6c6f9672e2 [ruby/json] parser.c: Pass the JSON_ParserConfig pointer
Doesn't make a measurable performance difference but is a
bit clearer.

314d117c61
2025-01-20 16:09:00 +09:00
Jean Boussier
f664e863d8 [ruby/json] Use RSTRING_END
dd9c46c805
2025-01-20 16:09:00 +09:00
Jean Boussier
e4b54b0a36 [ruby/json] Replace fbuffer by stack buffers or RB_ALLOCV in parser.c
We only use that buffer for parsing integer and floats, these
are unlikely to be very big, and if so we can just use RB_ALLOCV as it will
almost always end in a small `alloca`.

This allow to no longer need `rb_protect` around the parser.

994859916a
2025-01-20 16:09:00 +09:00
Jean Boussier
99e9eb5380 [ruby/json] Implement write barriers for ParserConfig objects
591056a526
2025-01-20 16:09:00 +09:00
Jean Boussier
ef585744c0 Finalize Kevin's handrolled parser.
And get rid of the Ragel parser.

This is 7% faster on activitypub, 15% after on twitter and 11% faster
on citm_catalog.

There might be some more optimization opportunities, I did a quick
optimization pass to fix a regression in string parsing, but other
than that I haven't dug much in performance.
2025-01-20 16:09:00 +09:00
Charles Oliver Nutter
1574b90451 [ruby/psych] Bump version for release
2af9f6ac02
2025-01-17 15:15:39 +00:00
Hiroshi SHIBATA
721891688b
Migrate win32ole as bundled gems 2025-01-16 12:35:21 +09:00
Charles Oliver Nutter
a50d612a0c [ruby/psych] Update to SnakeYAML-Engine 2.9
Fixes ruby/psych#689

ac887cdc76
2025-01-15 22:12:25 +00:00
Aaron Patterson
cd0abd696f [ruby/psych] remove vim settings
2f46abf4e1
2025-01-15 20:11:51 +00:00
Nobuyoshi Nakada
e0be1b9025
Link bin as well as lib so that Gem.bin_path works 2025-01-15 15:19:05 +09:00
Kazuki Yamaguchi
318519caaa [ruby/openssl] engine: remove mention of LibreSSL from OpenSSL::Engine
These paths are only reachable when it is compiled against OpenSSL.
LibreSSL 3.9 does not support ENGINE and defines OPENSSL_NO_ENGINE.

e153d6ab47
2025-01-14 12:38:17 +00:00
Kazuki Yamaguchi
731d3ec301 [ruby/openssl] ossl.c: use OPENSSL_init_ssl() and OpenSSL_version() with LibreSSL
LibreSSL 2.7.0 added support for OPENSSL_init_ssl() and
OpenSSL_version().

1328415097
2025-01-14 12:38:16 +00:00
Kazuki Yamaguchi
0fb64bda9b [ruby/openssl] Require LibreSSL 3.9 or later
Drop support for LibreSSL 3.1-3.8. LibreSSL 3.8 has reached its EOL in
2024-10.

f33d611f9f
2025-01-14 12:38:16 +00:00
Jean Boussier
4f79485889 [ruby/openssl] Refactor buffer usage to only use append_as_bytes
28f2901c48
2025-01-14 11:54:47 +00:00
Jean Boussier
2f5d31d38a [ruby/openssl] Reduce OpenSSL::Buffering#do_write overhead
[Bug #20972]

The `rb_str_new_freeze` was added in https://github.com/ruby/openssl/issues/452
to better handle concurrent use of a Socket, but SSL sockets can't be used
concurrently AFAIK, so we might as well just error cleanly.

By using `rb_str_locktmp` we can ensure attempts at concurrent write
will raise an error, be we avoid causing a copy of the bytes.

We also use the newer `String#append_as_bytes` method when available
to save on some more copies.

0d8c17aa85

Co-Authored-By: luke.gru@gmail.com
2025-01-14 11:54:47 +00:00
ydah
eafba0d5d3 Use LRAMA instead of BISON 2025-01-14 17:20:02 +09:00
Jean Boussier
2f0741dd3c [ruby/json] Fix a method redefinition warning in C parser
Ref: https://github.com/ruby/json/pull/728
Ref: https://github.com/ruby/ruby/pull/12569

30a4a86954
2025-01-14 09:08:02 +01:00
Jean Boussier
599fbeaffa [ruby/json] Refactor JSON::Ext::Parser to split configuration and parsing state
Ref: https://github.com/ruby/json/pull/718

The existing `Parser` interface is pretty bad, as it forces to
instantiate a new instance for each document.

Instead it's preferable to only take the config and do all the
initialization needed, and then keep the parsing state on the
stack on in ephemeral memory.

This refactor makes the `JSON::Coder` pull request much easier to
implement in a performant way.

c8d5236a92

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-01-14 09:08:02 +01:00
Étienne Barrié
f301383cdd Remove Generator::State#_generate
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-01-14 12:24:37 +09:00
Dmitrii
f1f81e8615 [ruby/fiddle] add regex for bool parsing & test struct w/ bool
parsing
(https://github.com/ruby/fiddle/pull/169)

GitHub: fix https://github.com/ruby/fiddle/pull/168

Struct parsing invokes "parse_ctype" on the whole member signature,
which fails if member type is "bool" due to plain string matching for
it. This change updates "bool" type matching to a regexp, so TYPE_BOOL
is correctly parsed for a whole signature like "bool toggle" as well as
just "bool".

---------

71607446d4

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2025-01-14 12:24:37 +09:00
Nobuyoshi Nakada
384e6945ac [ruby/date] Enclose dangling else in braces and fix -Wmisleading-indentation
```
date_strptime.c:253:324: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
  253 |   ...((VALUE)RUBY_Qtrue)); return 0; } while (0); si += l; } while (0);
      |                                                   ^
date_strptime.c:252:7: note: previous statement is here
  252 |       else
      |       ^
```

41aed5b746
2025-01-13 03:12:28 +00:00
Nobuyoshi Nakada
691c895289
Dependency: ext/-test-/memory_status/depend 2025-01-13 11:41:44 +09:00
yui-knk
84f0d2dd41 Stop passing -t and -v on ripper build
Both of them are debug option.
Let's use `YFLAGS` for parse.y build if needed.
2025-01-13 09:23:31 +09:00
Jean Boussier
f756950d82
Improve lookup tables for string escaping.
Introduce a simplified table for the most common case, which is
`script_safe: false, ascii_only: false`.

On the `script_safe` table, now only `0xE2` does a multi-byte check.

Merge back `convert_ASCII_to_JSON`, as it no longer help much with
the simplified escape table.

```
== Encoding mixed utf8 (5003001 bytes)
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
               after    38.000 i/100ms
Calculating -------------------------------------
               after    398.220 (± 3.0%) i/s    (2.51 ms/i) -      2.014k in   5.061659s

Comparison:
              before:      381.8 i/s
               after:      398.2 i/s - same-ish: difference falls within error

== Encoding mostly utf8 (5001001 bytes)
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
               after    39.000 i/100ms
Calculating -------------------------------------
               after    393.337 (± 2.5%) i/s    (2.54 ms/i) -      1.989k in   5.059397s

Comparison:
              before:      304.3 i/s
               after:      393.3 i/s - 1.29x  faster

== Encoding twitter.json (466906 bytes)
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
               after   244.000 i/100ms
Calculating -------------------------------------
               after      2.436k (± 0.9%) i/s  (410.43 μs/i) -     12.200k in   5.007702s

Comparison:
              before:     2125.9 i/s
               after:     2436.5 i/s - 1.15x  faster
```
2025-01-07 13:21:46 +09:00
ydah
de8deb5f9c Remove unused token definitions for tRPAREN in Ripper and parser files 2025-01-07 07:17:55 +09:00
Raul Gutierrez Segales
7ec233c85b Fix typo for private constant in Socket
Signed-off-by: Raul Gutierrez Segales <rgs@itevenworks.net>
2025-01-06 15:41:49 +09:00
mark-young-atg
c8eaad1804 [ruby/stringio] Provide a 'Changelog' link on
rubygems.org/gems/stringio
(https://github.com/ruby/stringio/pull/111)

By providing a 'changelog_uri' in the metadata of the gemspec a
'Changelog' link will be shown on https://rubygems.org/gems/stringio
which makes it quick and easy for someone to check on the changes
introduced with a new version.

Details of this functionality can be found on
https://guides.rubygems.org/specification-reference/#metadata

---------

8c084bfcdb

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2025-01-02 23:21:31 +00:00
Nobuyoshi Nakada
e109400748
Win32: Fix sub make commands
`cmd.exe` built-in `cd` does not recognize slashes as path separators,
replace to backslashes.
2024-12-27 16:26:14 +09:00
Nobuyoshi Nakada
731a53253f
Win32: clean extra object file 2024-12-27 12:33:28 +09:00
Hiroshi SHIBATA
5fab10999d Bump up fiddle 1.1.7.dev and stringio 3.1.3.dev 2024-12-26 10:27:24 +09:00
Ryan Bigg
778e73b2b3 [ruby/date] Simplify description of this library
904d4b9607
2024-12-26 10:27:24 +09:00
Nobuyoshi Nakada
2acbf45d36
[DOC] Monitor 2024-12-25 13:16:14 +09:00
Nobuyoshi Nakada
871124c3ea
[DOC] Stop document Ripper::Lexer
`:nodoc:` seems not working for inner classes.
2024-12-25 13:07:22 +09:00
Nobuyoshi Nakada
e46314edd1
[DOC] Monitor 2024-12-25 10:30:40 +09:00
Misaki Shioi
3be1baab82
Introduce a timeout to prevent rb_thread_fd_select from hanging with write(2) failure (#12457)
Rarely, there are cases where a write(2) call from a child thread
to notify the main thread of the completion of name resolution fails.
If this happens while the main thread is waiting in `rb_thread_fd_select`,
rb_thread_fd_select may not notice that the name resolution has completed and end up hanging.

This issue becomes a problem when there are no sockets currently being connected,
no addresses ready for immediate connection attempts,
and name resolution has already completed for one address family
while the main thread is waiting for the name resolution of the other address family.
(If name resolution is not completed for either address family,
the chances of write(2) failing in both child threads are likely low.)

To avoid this issue, a timeout is introduced to rb_thread_fd_select under the above conditions.
This way, even if the issue occurs,
the completion of name resolution should still be detected
in the subsequent `if (!resolution_store.is_all_finished) ...` block.
2024-12-25 03:06:02 +09:00
Misaki Shioi
34e6bb48af
Improve doc for Socket::ResolutionError (#12434)
Also, a topic about Socket::ResolutionError is added to NEWS
2024-12-23 15:05:00 +09:00
Koichi Sasada
c695536cc8 use st_update to prevent table extension
to prevent the following scenario:

1. `delete_unique_str()` can be called while GC (sweeping)
2. it calls `st_insert()` to decrement the counter
3. `st_insert()` can try to extend the table even if the key exists
4. `xmalloc` while GC and cause BUG
2024-12-23 11:05:34 +09:00
Kazuki Yamaguchi
9e3e1c7fc9 [ruby/openssl] Ruby/OpenSSL 3.3.0
e5153dbbb4
2024-12-22 03:33:03 +09:00
Kazuki Yamaguchi
4862462097 [ruby/openssl] digest: remove optional parameter from OpenSSL::Digest#finish
OpenSSL::Digest#finish overrides Digest::Instance#finish and is called
from the Digest::Class framework in the digest library. This method is
not supposed to take any arguments, as suggested by the RDoc comment for
Digest::Instance#finish.

It is a private method and not exposed to users. Let's remove it.

This optional parameter exists since r15602 in Ruby trunk, the commit
which converted OpenSSL::Digest to a subclass of Digest::Class.

dcb2a4f30b
2024-12-22 03:33:03 +09:00
Kazuki Yamaguchi
9de2b407d7 [ruby/openssl] digest: make output buffer String independent in #finish
Likewise, OpenSSL::Digest#finish needs to make the output buffer
independent before writing to it.

9cc8a83466
2024-12-22 03:33:03 +09:00
Kazuki Yamaguchi
637f019f1f [ruby/openssl] cipher: make output buffer String independent
OpenSSL::Cipher#update accepts a String as the second argument to be
used as the output buffer. The buffer must be directly writable, in
other words, it must not be frozen and not a shared string.

rb_str_resize() does not make the String independent if the String
already has the intended length. Use the rb_str_modify() family instead
to check it.

Fixes: https://bugs.ruby-lang.org/issues/20937

1de3b80a46
2024-12-22 03:33:03 +09:00
Kazuki Yamaguchi
c79b435407 [ruby/openssl] pkcs12: add PKCS12#set_mac
Add a binding for PKCS12_set_mac() to set MAC parameters and
(re-)calculate MAC for the content.

This allows generating PKCS #12 with consistent MAC parameters with
different OpenSSL versions. OpenSSL 3.0 changed the default hash
function used for HMAC and the KDF from SHA-1 to SHA-256.

Fixes: https://github.com/ruby/openssl/issues/772

f5ed2a74b6
2024-12-22 03:33:03 +09:00
Peter Zhu
a58675386c Prefix asan_poison_object with rb 2024-12-19 09:14:34 -05:00
Jean Boussier
91efe7b64f [ruby/json] Release 2.9.1
f745ec145e
2024-12-19 08:45:31 +09:00
Naohisa Goto
979b19b741 [ruby/json] Add support for Solaris 10 which lacks strnlen()
Check for existence of strnlen() and use alternative code if it is missing.

48d4bbc3a0
2024-12-19 08:45:31 +09:00
Hiroshi SHIBATA
3edbf6cfc5 [ruby/psych] Bump up v5.2.2
746e1ad24d
2024-12-18 10:27:03 +09:00
Misaki Shioi
498d6eb114
Wrap do_fast_fallback_getaddrinfo with rb_thread_prevent_fork (#12366)
Wrap `do_fast_fallback_getaddrinfo` with `rb_thread_prevent_fork`

Referencing PR #10864,
wrap `do_fast_fallback_getaddrinfo` with `rb_thread_prevent_fork`
to avoid fork safety issues.

`do_fast_fallback_getaddrinfo` internally uses getaddrinfo(3),
leading to fork safety issues, as described in PR #10864.
This change ensures that `do_fast_fallback_getaddrinfo`
is guarded by `rb_thread_prevent_fork`,
preventing fork during its execution and avoiding related issues.
2024-12-18 09:48:26 +09:00