Commit graph

9854 commits

Author SHA1 Message Date
Jean Boussier
d565d809af
[ruby/json] Release 2.12.2
a29cb77d52
2025-05-26 11:46:12 +09:00
Jean Boussier
54a314233c
[ruby/json] Release 2.12.1
8603a57a91
2025-05-26 11:46:12 +09:00
Jean Boussier
212213a552
[ruby/json] fbuffer.c: add debug mode with bound checks.
This would have caught https://github.com/ruby/json/pull/808
on CI.

8109421fb4
2025-05-26 11:46:12 +09:00
Jean Boussier
f171a263f7
[ruby/json] Fix: generate_json_float to reserve enough memory for large negative floats.
Fix: https://github.com/ruby/json/issues/807

Since https://github.com/ruby/json/pull/800, `fpconv_dtoa` can actually
generate up to 28 chars.

d73ae93d3c
2025-05-26 11:46:12 +09:00
Aaron Patterson
1c66124273 Make Addrinfo objects Ractor shareable
Allow Addrinfo objects to be shared among Ractors.  Addrinfo objects are
already immutable, so I think it's safe for us to tag them as
RUBY_TYPED_FROZEN_SHAREABLE shareable too.
2025-05-20 18:04:37 -07:00
Jean Boussier
4759550967
[ruby/json] Remove some unnecessary top level constant lookups
7c03ffc3e0
2025-05-19 11:19:17 +09:00
GrantBirki
e4a44b1f2a
[ruby/json] remove redundant self.
c060943d04
2025-05-19 11:19:17 +09:00
GrantBirki
9b25023fe4
[ruby/json] use . over :: for consistency
f5c1b8c45d
2025-05-19 11:19:17 +09:00
Cody Horton
3468811ed1
[ruby/json] fix for pretty_generate throwing wrong number of arguments error
8433571dcf
2025-05-19 11:19:17 +09:00
Kazuki Yamaguchi
06a56a7ffc [ruby/openssl] ssl: fix potential memory leak in SSLContext#setup
If SSL_CTX_add_extra_chain_cert() fails, the refcount of x509 must be
handled by the caller. This should only occur due to a malloc failure
inside the function.

80bcf727dc
2025-05-15 16:51:15 +00:00
Kazuki Yamaguchi
b43c7cf8c4 [ruby/openssl] cipher: remove Cipher#encrypt(password, iv) form
OpenSSL::Cipher#encrypt and #decrypt have long supported a hidden
feature to derive a key and an IV from the String argument, but in an
inappropriate way.

This feature is undocumented, untested, and has been deprecated since
commit 0dc43217b1 on 2004-06-30,
which started printing a non-verbose warning. More than 20 years later,
it must be safe to remove it entirely.

The deprecated usage:

	# `password` is a String, `iv` is either a String or nil
	cipher = OpenSSL::Cipher.new("aes-256-cbc")
	cipher.encrypt(password, iv)
	p cipher.update("data") << cipher.final

was equivalent to:

	cipher = OpenSSL::Cipher.new("aes-256-cbc")
	cipher.encrypt

	iv ||= "OpenSSL for Ruby rulez!"
	key = ((cipher.key_len + 15) / 16).times.inject([""]) { |ary, _|
	  ary << OpenSSL::Digest.digest("MD5", ary.last + password + iv[0, 8].ljust(8, "\0"))
	}.join
	cipher.key = key[...cipher.key_len]
	cipher.iv = iv[...cipher.iv_len].ljust(cipher.iv_len, "\0")
	p cipher.update("data") << cipher.final

e46d992ea1
2025-05-15 16:50:25 +00:00
Jean Boussier
60ffb714d2 Ensure shape_id is never used on T_IMEMO
It doesn't make sense to set ivars or anything shape
related on a T_IMEMO.

Co-Authored-By: John Hawthorn <john@hawthorn.email>
2025-05-15 16:06:52 +02:00
Jean Boussier
9420fc8ad6 [ruby/stringio] Add a comment to explicit RUBY_FL_USER2 |
RUBY_FL_USER3
(https://github.com/ruby/stringio/pull/133)

This way when someone removes these flags from Ruby or update them,
they'll find this reference when greping.

Followup: https://github.com/ruby/stringio/pull/128

fad26ee14b
2025-05-13 17:15:16 +00:00
Samuel Williams
425fa0aeb5
Make waiting_fd behaviour per-IO. (#13127)
- `rb_thread_fd_close` is deprecated and now a no-op.
- IO operations (including close) no longer take a vm-wide lock.
2025-05-13 19:02:03 +09:00
Jean Boussier
cd7495a1d0 [ruby/json] Further improve parsing errors
Report EOF when applicable instead of an empty fragment.

Also stop fragment extraction on first whitespace.

cc1daba860
2025-05-13 14:12:22 +09:00
Jean Boussier
8cc1aa82f1 [ruby/json] Add missing single quotes in error messages
f3dde3cb2f
2025-05-13 14:12:22 +09:00
Jean Boussier
73d0bd5e90 [ruby/json] Release 2.12.0
41f1f6939d
2025-05-13 14:12:22 +09:00
Jean Boussier
50ef208369 [ruby/json] parser.c: include line and column in error messages
30e35b9ba5
2025-05-13 14:12:22 +09:00
Jean Boussier
8f008598c3 [ruby/json] parser.c: refactor raise_parse_error to have document start
832b5b1a4c
2025-05-13 14:12:22 +09:00
Takashi Kokubun
a93d9fdcd2 Add a missing dependency for stringio
18d395e078
2025-05-12 21:10:04 -07:00
Jeremy Evans
5e59ae186f [ruby/stringio] Fix Ruby 3.4 check
a27c5d5e2e

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2025-05-13 03:20:09 +00:00
Jeremy Evans
18d395e078 [ruby/stringio] Do not issue warning when calling set_encoding if string is chilled
StringIO does not warn for unchilled unfrozen string or for frozen
string, so it should not warn for chilled string.

4ac33b8c70
2025-05-13 03:20:09 +00:00
Aaron Patterson
957473d87f [ruby/psych] Bump version for release
b9dec9f811
2025-05-12 16:21:41 +00:00
Earlopain
0c94ae048a [ruby/psych] Fix dumping StringIO (and potentially others) on Ruby <= 2.7
In Ruby < 3.0, the superclass of StringIO was actually already `Data`,
but it doesn't have the expected shape. So, on these earlier versions it errors:
> NoMethodError: undefined method `members' for #<StringIO:0x00005641dd5f2880>
>    vendor/bundle/ruby/2.6.0/gems/psych-5.2.5/lib/psych/visitors/yaml_tree.rb:170:in `visit_Data'

This test doesn't fail on 2.7, presumably because it can pull in a newer `stringio` version.

0f40f56268
2025-05-12 16:19:38 +00:00
Nobuyoshi Nakada
311b9352a1 [ruby/erb] [DOC] Make documentation 100%
9152ce8db4
2025-05-12 13:57:24 +00:00
Nobuyoshi Nakada
d2ffdb1088 Explicit cast down from double to int 2025-05-12 17:45:39 +09:00
Jean Boussier
af79914002 [ruby/json] Favor decimal notation over scientific notation for floats
e.g.
```
JSON.dump(1746861937.7842371)
```

master:
```
"1.7468619377+9"
```

This branch and older json versions:
```
1746861937.7842371
```

In the end it's shorter, and according to `canada.json` benchmark
performance is the same.

866f72a437
2025-05-12 11:09:11 +09:00
Yusuke Endoh
cb99e54486 Update common.mk dependencies 2025-05-11 23:32:50 +09:00
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
Aaron Patterson
58c008e68f [ruby/psych] Bump version for release
dbf9e36583
2025-05-09 22:12:47 +00:00
OrenGitHub
ae299cc9cd [ruby/psych] add first test for safe load stream
336553b412
2025-05-09 17:53:17 +00:00
OrenGitHub
f0e2a41d4b [ruby/psych] fixed bugs from testing
e954f96639
2025-05-09 17:53:17 +00:00
OrenGitHub
d69319304f [ruby/psych] Add safe version for load_stream
30a2a5ee94
2025-05-09 17:53:17 +00:00
Jean Boussier
ea77250847 Rename RB_OBJ_SHAPE -> rb_obj_shape
As well as `RB_OBJ_SHAPE_ID` -> `rb_obj_shape_id`
and `RSHAPE` is now a simple alias for `rb_shape_lookup`.

I tried to turn all these into `static inline` but I'm having
trouble with `RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;`
not being exposed as I'd expect.
2025-05-09 10:22:51 +02:00
Jean Boussier
5782561fc1 Rename rb_shape_get_shape_id -> RB_OBJ_SHAPE_ID
And `rb_shape_get_shape` -> `RB_OBJ_SHAPE`.
2025-05-09 10:22:51 +02:00
Jean Boussier
3f7c0af051 Rename rb_shape_obj_too_complex -> rb_shape_obj_too_complex_p 2025-05-09 10:22:51 +02:00
Jean Boussier
e4f97ce387 Refactor rb_shape_depth to take an ID rather than a pointer.
As well as `rb_shape_edges_count` and `rb_shape_memsize`.
2025-05-09 10:22:51 +02:00
Hiroshi SHIBATA
8a1d45144b Support require 'cgi/escape' with extracting CGI::Escape from CGI::Util 2025-05-09 14:27:28 +09:00
Nobuyoshi Nakada
f3006c26de Add depend files under ext/-test- 2025-05-08 18:20:51 +09:00
Nobuyoshi Nakada
61b6f226e8
[ruby/json] Constify static data in fpconv.c
3b605d9b1e
2025-05-08 18:03:04 +09:00
Jean Boussier
1f2a9dc2a9
[ruby/psych] Refine Ruby 3.5 Set support.
Use feature testing to detect native Set,
and don't rely on `Set#to_h` which wasn't intended
as a public method.

d58cff11af
2025-05-08 18:03:04 +09:00
Jean Boussier
f48e45d1e9 Move object_id in object fields.
And get rid of the `obj_to_id_tbl`

It's no longer needed, the `object_id` is now stored inline
in the object alongside instance variables.

We still need the inverse table in case `_id2ref` is invoked, but
we lazily build it by walking the heap if that happens.

The `object_id` concern is also no longer a GC implementation
concern, but a generic implementation.

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2025-05-08 07:58:05 +02:00
Jean Boussier
0ea210d1ea Rename ivptr -> fields, next_iv_index -> next_field_index
Ivars will longer be the only thing stored inline
via shapes, so keeping the `iv_index` and `ivptr` names
would be confusing.

Instance variables won't be the only thing stored inline
via shapes, so keeping the `ivptr` name would be confusing.

`field` encompass anything that can be stored in a VALUE array.

Similarly, `gen_ivtbl` becomes `gen_fields_tbl`.
2025-05-08 07:58:05 +02:00
Hiroshi SHIBATA
4e30b77b90 Added depend file for test/-ext-/econv/test_append.rb
ce51ef30df broke
ext/-test-/econv/append.o. We should rebuild that object file when dependencies are updated.
2025-05-08 12:34:22 +09:00
Nobuyoshi Nakada
5b1a61e29c [ruby/digest] stringop-overread warning is since GCC 11
d16853fe8c
2025-05-05 10:20:31 +00:00
Misaki Shioi
2be117a97d
Fix heap-use-after-free in free_fast_fallback_getaddrinfo_entry (#13231)
This change addresses the following ASAN error:

```
==36597==ERROR: AddressSanitizer: heap-use-after-free on address 0x512000396ba8 at pc 0x7fcad5cbad9f bp 0x7fff19739af0 sp 0x7fff19739ae8
  WRITE of size 8 at 0x512000396ba8 thread T0
  [643/756] 36600=optparse/test_summary
      #0 0x7fcad5cbad9e in free_fast_fallback_getaddrinfo_entry /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/raddrinfo.c:3046:22
      #1 0x7fcad5c9fb48 in fast_fallback_inetsock_cleanup /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1179:17
      #2 0x7fcadf3b611a in rb_ensure /home/runner/work/ruby-dev-builder/ruby-dev-builder/eval.c:1081:5
      #3 0x7fcad5c9b44b in rsock_init_inetsock /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1289:20
      #4 0x7fcad5ca22b8 in tcp_init /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/tcpsocket.c:76:12
      #5 0x7fcadf83ba70 in vm_call0_cfunc_with_frame /home/runner/work/ruby-dev-builder/ruby-dev-builder/./vm_eval.c:164:15
...
```

A `struct fast_fallback_getaddrinfo_shared` is shared between the main thread and two child threads.
This struct contains an array of `fast_fallback_getaddrinfo_entry`.

`fast_fallback_getaddrinfo_entry` and `fast_fallback_getaddrinfo_shared` were freed separately, and if `fast_fallback_getaddrinfo_shared` was freed first and then an attempt was made to free a `fast_fallback_getaddrinfo_entry`, a `heap-use-after-free` could occur.

This change avoids that possibility by separating the deallocation of the addrinfo memory held by `fast_fallback_getaddrinfo_entry` from the access and lifecycle of the `fast_fallback_getaddrinfo_entry` itself.
2025-05-03 21:39:57 +09:00
Nobuyoshi Nakada
85198262a3 [ruby/digest] Suppress false stringop-overread warning
0df846e8c1
2025-05-02 09:46:51 +00:00
Nobuyoshi Nakada
277bcb717b [ruby/digest] Move macros for warnings to defs.h
70a805b872
2025-05-02 09:46:51 +00:00
Nobuyoshi Nakada
ba6a36e653 [ruby/digest] Fix --without-common-digest option
In `digest_conf`, "no implicit conversion of false into String"
TypeError is raised.

89e5e5fe3a
2025-05-02 09:20:47 +00:00
Hiroshi SHIBATA
0f06626915
Bump up strscan version to 3.1.5.dev 2025-05-02 10:11:09 +09:00