Commit graph

89439 commits

Author SHA1 Message Date
zverok
e76d2fddad [DOC] Fix typo in related class reference 2024-12-22 15:07:56 +09:00
Kazuki Yamaguchi
9e3e1c7fc9 [ruby/openssl] Ruby/OpenSSL 3.3.0
e5153dbbb4
2024-12-22 03:33:03 +09:00
Kazuki Yamaguchi
2a3f2412b7 [ruby/openssl] ssl: fix flaky test case test_ctx_client_session_cb_tls13_exception
In the test case, the client raises an exception in the session_new_cb
and may not cleanly close the connection. Let's ignore exceptions raised
at the server side.

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

210ba0334a
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
Victor Shepelev
78f55ccd9b
[DOC] Move Time#xmlschema docs to the core (#12403) 2024-12-21 20:06:48 +02:00
Victor Shepelev
efe671f9d3
Properly document Ractor#require (#12389) 2024-12-21 20:05:26 +02:00
Takashi Kokubun
6114094aa0 [DOC] Resurrected YJIT section
under "Implementation improvements", similarly to past versions.

We also don't do categorization like "* New features" (which was in this
file) or "New features:" (which was on the release notes), so I used the
standard header format instead.

I applied the same change to release notes, copied the same thing back
to NEWS.md, and then removed the TL;DR section from it.
2024-12-20 17:45:52 -08:00
Takashi Kokubun
861ee7a321 [DOC] Reorder Language changes entries a little
Warnings aren't something to brag first on the release notes. So I
lowered the string literal one just a little. However, it still seems
significant compared to other Bug tickets and incompatibilities/warnings,
so I still kept it relatively high.
2024-12-20 17:40:33 -08:00
John Hawthorn
018b775039 FREE_AT_EXIT: Free all allocations from fiber pool
The fiber pool allocations form a singly-linked list, so when we're
running with RUBY_FREE_AT_EXIT we need to walk the linked list freeing
each element, otherwise it can be detected as a memory leak.
2024-12-20 14:21:57 -08:00
Peter Zhu
36966456c7 GC guard lookup_name
When searching for native extensions, if the name does not end in ".so"
then we create a new string and append ".so" so it. If the native extension
is in static_ext_inits, then we could trigger a GC in the rb_filesystem_str_new_cstr.
This could cuase the GC to free lookup_name since we don't use the local
variable anymore.

This bug was caught in this ASAN build:
http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5479182

    ==435614==ERROR: AddressSanitizer: use-after-poison on address 0x715a63022da0 at pc 0x5e7463873e4e bp 0x7fff383c8b00 sp 0x7fff383c82c0
    READ of size 14 at 0x715a63022da0 thread T0
        #0 0x5e7463873e4d in __asan_memcpy (/tmp/ruby/build/trunk_asan/ruby+0x214e4d) (BuildId: 607411c0626a2f66b4c20c02179b346aace20898)
        #1 0x5e7463b50a82 in memcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10
        #2 0x5e7463b50a82 in ruby_nonempty_memcpy /tmp/ruby/src/trunk_asan/include/ruby/internal/memory.h:671:16
        #3 0x5e7463b50a82 in str_enc_new /tmp/ruby/src/trunk_asan/string.c:1035:9
        #4 0x5e74639b97dd in search_required /tmp/ruby/src/trunk_asan/load.c:1126:21
        #5 0x5e74639b97dd in require_internal /tmp/ruby/src/trunk_asan/load.c:1274:17
        #6 0x5e74639b83c1 in rb_require_string_internal /tmp/ruby/src/trunk_asan/load.c:1401:22
        #7 0x5e74639b83c1 in rb_require_string /tmp/ruby/src/trunk_asan/load.c:1387:12
2024-12-20 16:52:36 -05:00
Kevin Newton
391b6746cd Provide Ractor support for **
Fixes [Bug #20916]
2024-12-20 16:45:28 -05:00
Peter Zhu
97f5546676 Don't print bug report in asan_death_callback when no VM
If we don't have the VM (e.g. printing memory leaks in LSAN after shutdown)
then we will crash when we try to print the bug report. This issue was
reported in: https://github.com/ruby/ruby/pull/12309#issuecomment-2555766525
2024-12-20 15:04:08 -05:00
Matt Valentine-House
aa360c3bee [DOC] Fix to GC.config docs 2024-12-20 19:51:53 +00:00
Matt Valentine-House
07724d7b6f [DOC] Document the :implementation key of GC.config 2024-12-20 19:47:01 +00:00
Stan Lo
5d1fde06d4
[DOC] Refresh standard libraries page (#12404)
* Migrate standard library doc page to markdown

* Improve libraries listing and link to source code

* Fix grammar and improve phrasing

Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2024-12-20 10:57:02 -08:00
Earlopain
83a34fb060 [DOC] Don't document gemspec files
Since cf711863cb, gemspecs are included because the default exclude is overwritten
2024-12-20 10:55:36 -08:00
Peter Zhu
e23a60b929 Fix GC compaction crash when using local variables in eval
If we have local variables outside of the eval, the local variables names
are IDs. We convert these IDs to char * using rb_id2name. However, these
char * are actually Ruby strings, which may be embedded. This means that
it is not safe to rb_id2name and call any potential GC entrypoints because
if a GC compaction runs, the embedded string may move and the pointer will
change.

For example, if you compile with `-DRGENGC_CHECK_MODE=1`, then the following
script will crash:

    GC.auto_compact = :empty
    GC.stress = true

    o = Object.new

    eval("def o.m(k: 0) k end")

The crash message is:

    test.rb:6: [BUG] Local with constant_id 1 does not exist
    ruby 3.4.0dev (2024-12-17T18:34:57Z prism-local-compac.. 434346726c) +PRISM [arm64-darwin24]

    -- C level backtrace information -------------------------------------------
    miniruby(rb_print_backtrace+0x24) [0x10312fec4] vm_dump.c:823
    miniruby(rb_print_backtrace) (null):0
    miniruby(rb_vm_bugreport+0x2d4) [0x1031301b8] vm_dump.c:1155
    miniruby(rb_bug_without_die_internal+0xa8) [0x102dd6a94] error.c:1097
    miniruby(rb_bug+0x28) [0x102dd6b00] error.c:1115
    miniruby(pm_lookup_local_index+0xec) [0x102d61e4c] prism_compile.c:1237
    miniruby(pm_compile_node+0x45d0) [0x102d252f4] prism_compile.c:9334
    miniruby(pm_compile_node+0x1864) [0x102d22588] prism_compile.c:8650
    miniruby(pm_compile_node+0x65ec) [0x102d27310] prism_compile.c:9897
    miniruby(pm_compile_scope_node+0x3008) [0x102d77bcc] prism_compile.c:6584
    miniruby(pm_compile_node+0x5ec4) [0x102d26be8] prism_compile.c:9768
    miniruby(pm_iseq_compile_node+0xac) [0x102d20bf0] prism_compile.c:10069
    miniruby(pm_iseq_new_with_opt_try+0x2c) [0x102e7d088] iseq.c:1029
    miniruby(rb_protect+0x108) [0x102dea9bc] eval.c:1033
    miniruby(pm_iseq_new_with_opt+0x264) [0x102e7c444] iseq.c:1082
    miniruby(pm_iseq_new_eval+0xec) [0x102e7c8e0] iseq.c:961
    miniruby(pm_eval_make_iseq+0x594) [0x1031209cc] vm_eval.c:1770
    miniruby(eval_make_iseq+0x54) [0x103120068] vm_eval.c:1799
2024-12-20 08:24:54 -05:00
Peter Zhu
85f3ed8cdb Don't recompute the strlen in pm_eval_make_iseq
We've already computed the length of the string, so we can reuse it.
2024-12-20 08:24:54 -05:00
Matt Valentine-House
e8d393c8ae [PRISM] Treat it as a local when compiling patterns
Fixes [Bug #20973]
2024-12-20 08:19:57 -05:00
Kazuki Yamaguchi
0397bfa2c8 [PRISM] Fix compiling popped opt_str_uminus and opt_str_freeze
Put a pop as needed. This example currently causes [BUG]:

	$ ruby --parser=prism -e'1.times{"".freeze;nil}'
	-e:1: [BUG] Stack consistency error (sp: 15, bp: 14)
	ruby 3.4.0dev (2024-12-20T00:48:01Z master 978df259ca) +PRISM [x86_64-linux]
2024-12-20 08:19:09 -05:00
Misaki Shioi
b53a75230f
Fix tests for fast_fallback (#12406)
* TCPSocket.new: Close resources in ensure

* TCPSocket.new: Remove unnecessary comments

* Socket.tcp: Make assert_separately in TestSocket more readable

* Socket.tcp: Returning instead of exiting

* Socket.tcp: Close resources in ensure

* Socket.tcp: Avoid test failures on hosts that only support IPv4
2024-12-20 18:55:26 +09:00
Matt Valentine-House
2f6c694977 Memerror is fatal if VM cannot be unlocked.
[Bug #20942]

If we've raised a memerror while the VM is locked, and the tag we're
jumping to has been locked at a different level to the current lock (ie.
we've locked the VM again since the tag we're jumping to) then we should
consider this memerror fatal and exit, since the tag cannot unlock the
VM.

Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
2024-12-20 07:49:30 +00:00
Soutaro Matsumoto
978df259ca
Bundle rbs-3.8 (#12399)
* Clean up skip tests

* Bundle rbs-3.8.0.pre.1
2024-12-20 09:48:01 +09:00
Stan Lo
2a44a57e14 [DOC] Link to special fatal class through rdoc-ref 2024-12-19 14:15:23 -08:00
Peter Zhu
33f95d632d Don't unpoison the CC in vm_ccs_free
The poison status is maintained by the GC, so don't unpoison it in vm_ccs_free.
If the object is not a garbage object, then it should not be poisoned.
2024-12-19 16:25:23 -05:00
Peter Zhu
84eff67644 [DOC] Add gc/README.md 2024-12-19 13:20:31 -05:00
Alan Wu
5978f2f114
Fix use-after-free in vm_ccs_free()
`struct rb_callcache *` point to an imemo object on the GC heap when
pushed into `struct rb_class_cc_entries`, but by the time vm_ccs_free()
runs, the entire GC page the imemo was on could already be deallocated.
With the right conditions, vm_ccs_free() wrote to freed memory.
rb_objspace_garbage_object_p() by itself is not enough to determine
liveness.

I conjectured this situation to be possible in
<https://github.com/ruby/ruby/pull/11995> using hints from crashes
in the wild. With c37bdfa531 ("Make
asan_poison_object poison the whole slot"), the in-tree test suite
now recreates this scenario[^1][^2][^3].

Use rb_gc_pointer_to_heap_p(). Other uses of
rb_objspace_garbage_object_p() could be making the same mistake, but
correcting them might introduce serious performance regressions, so
leave them alone for now.

[^1]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477412
[^2]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477445
[^3]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477448
2024-12-19 12:28:21 -05:00
Alan Wu
ce849d565b
ruby2_keywords warnings: Quote non-UTF8 method names fully
It used to quote only part of the method name because NUL byte in
the method terminates the C string:

```
(irb)> "abcdef".encode("UTF-16LE").bytes
=> [97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0]
```

```
expected: /abcdef/
actual: warning: Skipping set of ruby2_keywords flag for a (method not defined in Ruby)\n".
```
2024-12-19 10:32:14 -05:00
Nobuyoshi Nakada
7b2ae8df90
[Bug #20969] Pass assignable from ripper
For the universal parser, `rb_reg_named_capture_assign_iter_impl`
function is shared between the parser and ripper.  However
`parser_params` struct is partially different, and `assignable`
function depends on that part indirectly.
2024-12-19 23:20:09 +09:00
Peter Zhu
a58675386c Prefix asan_poison_object with rb 2024-12-19 09:14:34 -05:00
Peter Zhu
fcd44eee09 Fix compaction in ASAN with RGENGC_CHECK_MODE enabled 2024-12-19 09:14:34 -05:00
Peter Zhu
a72717675f Export asan_poison_object 2024-12-19 09:14:34 -05:00
Peter Zhu
16750a47d0 Don't calculate the aligned slot when unlocking page
If we try to use GET_PAGE_HEADER, it can trigger the read barrier. If we
try to align on the slot then we end up unlocking the heap page of a
lower memory address.
2024-12-19 09:14:34 -05:00
Peter Zhu
f02e31294c Don't unpoison a NULL object 2024-12-19 09:14:34 -05:00
Peter Zhu
a126560196 Unpoison memory before accessing next element of freelist 2024-12-19 09:14:34 -05:00
Peter Zhu
c37bdfa531 Make asan_poison_object poison the whole slot
This change poisons the whole slot of the object rather than just the flags.
This allows ASAN to find any reads/writes into the slot after it has been
freed.
2024-12-19 09:14:34 -05:00
Hiroshi SHIBATA
ccded855b6
Fixed label typo 2024-12-19 21:18:24 +09:00
Stan Lo
40af25d7fe
Fix bundled gems' indentations and link to their repos 2024-12-19 11:58:49 +00:00
Stan Lo
b009f94747
Link to default gems' github repos 2024-12-19 11:55:28 +00:00
Stan Lo
7cb071c951
Fix release entries' indentation 2024-12-19 11:52:44 +00:00
Kazuhiro NISHIYAMA
335bba0fde
[DOC] Remove Unused footnotes [ci skip] 2024-12-19 16:16:12 +09:00
Nobuyoshi Nakada
46fec0f62a
[Bug #20965] Define it like an ordinary argument (#12398)
Also fixes [Bug #20955]
2024-12-18 23:12:16 -08:00
Hiroshi SHIBATA
2783868de2
Update NEWS.md with debug-1.10.0 2024-12-19 13:44:56 +09:00
Hiroshi SHIBATA
a945c87aa8
Update with logger-1.6.4 2024-12-19 13:18:11 +09:00
Hiroshi SHIBATA
0275cc0524 [ruby/logger] v1.6.4
216cedef7c
2024-12-19 13:16:56 +09:00
Nobuyoshi Nakada
d16b043cdd [ruby/logger] Use __FILE__ for wasm
`/dev/null` is not available on wasm.

4be05c2208
2024-12-19 13:16:50 +09:00
Hiroshi SHIBATA
68e2022b5b The test of net-imap is passed with Windows 2024-12-19 12:20:22 +09:00