Commit graph

9970 commits

Author SHA1 Message Date
Jean Boussier
fb0dbbc0e6 [ruby/date] d_lite_marshal_load: copy ivars in the right order
dbf4e957dc
2025-06-13 17:46:10 +00:00
Jean Boussier
99a72df16d [ruby/date] Remove references to FL_EXIVAR
This flag isn't really meant to be public, it's an implementation
detail of Ruby.

And checking it before calling `rb_copy_generic_ivar` only save
a function call.

8175252653
2025-06-13 17:40:43 +00:00
Jean Boussier
3abdd4241f Turn rb_classext_t.fields into a T_IMEMO/class_fields
This behave almost exactly as a T_OBJECT, the layout is entirely
compatible.

This aims to solve two problems.

First, it solves the problem of namspaced classes having
a single `shape_id`. Now each namespaced classext
has an object that can hold the namespace specific
shape.

Second, it open the door to later make class instance variable
writes atomics, hence be able to read class variables
without locking the VM.
In the future, in multi-ractor mode, we can do the write
on a copy of the `fields_obj` and then atomically swap it.

Considerations:

  - Right now the `RClass` shape_id is always synchronized,
    but with namespace we should likely mark classes that have
    multiple namespace with a specific shape flag.
2025-06-12 07:58:16 +02:00
Nobuyoshi Nakada
4585ccd90f [ruby/strscan] Update extconf.rb
(https://github.com/ruby/strscan/pull/158)

- `have_func` includes "ruby.h" by default.
- include "ruby/re.h" where `rb_reg_onig_match` is declared.

1ac96f47e9
2025-06-12 10:34:31 +09:00
Jean Boussier
95201299fd Refactor the last references to rb_shape_t
The type isn't opaque because Ruby isn't often compiled with LTO,
so for optimization purpose it's better to allow as much inlining
as possible.

However ideally only `shape.c` and `shape.h` should deal with
the actual struct, and everything else should just deal with opaque
`shape_id_t`.
2025-06-11 16:38:38 +02:00
Nobuyoshi Nakada
f45aa1505f [ruby/date] Update zonetab.h at 2025-06-11
b28617cde0
2025-06-11 10:05:39 +00:00
Jean Boussier
6eb0cd8df7 Get rid of SHAPE_T_OBJECT
Now that we have the `heap_index` in shape flags we no longer
need `T_OBJECT` shapes.
2025-06-07 18:30:44 +02:00
Hiroshi SHIBATA
9f00044d0f
Bump up strscan version to 3.1.6.dev 2025-06-06 11:30:14 +09:00
Daniel Colson
deb70925a2 [ruby/strscan] Implement Write Barrier
(https://github.com/ruby/strscan/pull/156)

StringScanner holds the string being scanned, and a regex for methods
like `match?`. Triggering the write barrier for those allows us to mark
this as WB protected.

32fec70407
2025-06-06 11:29:42 +09:00
Nobuyoshi Nakada
998e5791c5 [ruby/date] Suppress warnings by gcc-13 with -Og
6dd7969a64
2025-06-05 14:18:38 +00:00
Nobuyoshi Nakada
edaa27ce45
Suppress warnings by gcc-13 with -Og 2025-06-05 22:33:02 +09:00
Nobuyoshi Nakada
8906d55cb5 [ruby/stringio] Extract internal part as the function
`str_chilled_p`
(https://github.com/ruby/stringio/pull/136)

3c52ddc4c8
2025-06-05 08:06:51 +00:00
Daniel Colson
3b5787a97f Implement write barrier for addrinfo
`rb_addrinfo_t` has `VALUE inspectname` and `VALUE canonname`, so this
triggers the write barrier for those. The `AddrInfo` wasn't readily
available where we need to call `RB_OBJ_WRITE`, so this involves passing
`self` around a bit.
2025-06-04 10:18:36 -07:00
Jean Boussier
675f33508c Get rid of TOO_COMPLEX shape type
Instead it's now a `shape_id` flag.

This allows to check if an object is complex without having
to chase the `rb_shape_t` pointer.
2025-06-04 13:13:50 +02:00
Jean Boussier
625d6a9cbb Get rid of frozen shapes.
Instead `shape_id_t` higher bits contain flags, and the first one
tells whether the shape is frozen.

This has multiple benefits:
  - Can check if a shape is frozen with a single bit check instead of
    dereferencing a pointer.
  - Guarantees it is always possible to transition to frozen.
  - This allow reclaiming `FL_FREEZE` (not done yet).

The downside is you have to be careful to preserve these flags
when transitioning.
2025-06-04 07:59:20 +02:00
Jean Boussier
e535f8248b Get rid of rb_shape_id(rb_shape_t *)
We should avoid conversions from `rb_shape_t *` into `shape_id_t`
outside of `shape.c` as the short term goal is to have `shape_id_t`
contain tags.
2025-05-27 12:45:24 +02:00
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