537 Commits

Author SHA1 Message Date
Nobuyoshi Nakada
78b7646bdb
[Bug #21842] Let rb_interned_str return US-ASCII if possible 2026-01-17 14:19:15 +09:00
Nobuyoshi Nakada
c794a97940 Rename alloca_overflow to stack_overflow
`alloca` is an implementation detail to raise a stack overflow.
2026-01-09 20:02:54 +09:00
Nobuyoshi Nakada
e01e13c239
Use assert_ruby_status if no assertion 2026-01-09 17:16:22 +09:00
Nobuyoshi Nakada
7780d3b6c3 Box: fix the environment variable name 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
f4c48505ca Box: move extensions from namespace to box 2025-12-16 16:53:13 +09:00
Samuel Williams
e2fe0aae43
Avoid race condition in test_without_handle_interrupt_signal_works. (#15504) 2025-12-12 22:12:41 +13:00
Jean Boussier
ccfd31162a Remove object_id in NEWOBJ tracepoint test
Generating an object_id for any type other than T_OBJECT (and T_CLASS)
will inevitably allocate an IMEMO/fields objects, which isn't supported
in a NEWOBJ tracepoint.

See: https://bugs.ruby-lang.org/issues/21710#note-23
2025-12-10 21:56:40 +01:00
Nobuyoshi Nakada
240afe50a1
Suppress noisy outputs
Fix up ruby/ruby#14700.
2025-12-07 00:38:25 +09:00
Samuel Williams
42f5654b69
Yield to scheduler if interrupts are pending. (#14700) 2025-12-06 21:44:14 +13:00
Jean Boussier
8c3909935e Handle NEWOBJ tracepoints settings fields
[Bug #21710]

- struct.c: `struct_alloc`

It is possible for a `NEWOBJ` tracepoint call back to write fields
into a newly allocated object before `struct_alloc` had the time
to set the `RSTRUCT_GEN_FIELDS` flags and such.

Hence we can't blindly initialize the `fields_obj` reference to `0`
we first need to check no fields were added yet.

- object.c: `rb_class_allocate_instance`

Similarly, if a `NEWOBJ` tracepoint tries to set fields on the object,
the `shape_id` must already be set, as it's required on T_OBJECT to
know where to write fields.

`NEWOBJ_OF` had to be refactored to accept a `shape_id`.
2025-12-03 08:14:56 +01:00
Peter Zhu
eb6e36a87d Skip tests in TestThreadLockNativeThread when using LSAN
These tests use NM threads but NT is not freed for MN thread, causing it
to be reported as memory leaks in LSAN. For example:

    #1 0x62ee7bc67e99 in calloc1 gc/default/default.c:1495:12
    #2 0x62ee7bc7ba00 in rb_gc_impl_calloc gc/default/default.c:8216:5
    #3 0x62ee7bc631d1 in ruby_xcalloc_body gc.c:5221:12
    #4 0x62ee7bc5cdbc in ruby_xcalloc gc.c:5215:34
    #5 0x62ee7bdea4c6 in native_thread_alloc thread_pthread.c:2187:35
    #6 0x62ee7bdec31b in native_thread_check_and_create_shared thread_pthread_mn.c:429:39
    #7 0x62ee7bdea484 in native_thread_create_shared thread_pthread_mn.c:531:12
    #8 0x62ee7bdea1da in native_thread_create thread_pthread.c:2403:16
    #9 0x62ee7bdde2eb in thread_create_core thread.c:884:11
    #10 0x62ee7bde4466 in thread_initialize thread.c:992:16
2025-11-14 14:26:09 -08:00
Satoshi Tagomori
aaf1f53df0 Follow renaming from Namespace to Ruby::Box 2025-11-07 13:14:54 +09:00
Satoshi Tagomori
50b9d9d355 rename namespace.c (and others) to box.c 2025-11-07 13:14:54 +09:00
Alan Wu
7ed1b24bf3 Unset RUBY_CRASH_REPORT in tests that crash on purpose 2025-09-17 13:35:35 -04:00
Takashi Kokubun
72ddfc131f
ZJIT: Fix tests for ZJIT (#14460) 2025-09-05 15:08:21 -07:00
Alan Wu
61d5fb213d ext/-test-/tracepoint/gc_hook.c: Fix GC safety issue
TestTracepointObj#test_teardown_with_active_GC_end_hook was failing on
some platforms due to a Proc that is not marked being passed around.
Neither rb_tracepoint_new() nor rb_postponed_job_preregister() promise
to mark their callback `void *data`.

https://rubyci.s3.amazonaws.com/osx1300arm/ruby-master/log/20250902T154504Z.fail.html.gz

Add a GC.start to make the test a better detector for this safety issue
and fix it by getting the Proc from an ivar on the rooted module.
2025-09-02 18:28:20 -04:00
Peter Zhu
87c4ebd001 Fix tests using assert_raise_with_message on US-ASCII systems
On systems where the Encoding.default_internal defaults to US-ASCII instead
of UTF-8, some tests using assert_raise_with_message can fail since it no
longer changes Encoding.default_internal in 79f5202.

This tests explicitly uses EnvUtil.with_default_internal on systems where
these tests fail.
2025-08-15 22:42:07 -04:00
Takashi Kokubun
2f2e2bd7cd
Relax a delta for an unstable test (#14246)
https://github.com/ruby/ruby/actions/runs/16995978143/job/48186652826?pr=14244
2025-08-15 11:13:11 -07:00
Hiroshi SHIBATA
d4ed7eb1ad
Relax delta value
https://github.com/ruby/ruby/actions/runs/15751511003/job/44397451542?pr=13649

```
    1) Failure:
  TestLastThread#test_last_thread [/Users/runner/work/ruby/ruby/src/test/-ext-/gvl/test_last_thread.rb:18]:
  Expected |1.0 - 1.167141| (0.16714099999999998) to be <= 0.16.
```
2025-06-19 16:49:28 +09:00
Hiroshi SHIBATA
255e6e6197 Try to run ignored tests with macOS 15 2025-06-11 15:40:52 +09:00
Koichi Sasada
ef2bb61018 Ractor::Port
* Added `Ractor::Port`
  * `Ractor::Port#receive` (support multi-threads)
  * `Rcator::Port#close`
  * `Ractor::Port#closed?`
* Added some methods
  * `Ractor#join`
  * `Ractor#value`
  * `Ractor#monitor`
  * `Ractor#unmonitor`
* Removed some methods
  * `Ractor#take`
  * `Ractor.yield`
* Change the spec
  * `Racotr.select`

You can wait for multiple sequences of messages with `Ractor::Port`.

```ruby
ports = 3.times.map{ Ractor::Port.new }
ports.map.with_index do |port, ri|
  Ractor.new port,ri do |port, ri|
    3.times{|i| port << "r#{ri}-#{i}"}
  end
end

p ports.each{|port| pp 3.times.map{port.receive}}

```

In this example, we use 3 ports, and 3 Ractors send messages to them respectively.
We can receive a series of messages from each port.

You can use `Ractor#value` to get the last value of a Ractor's block:

```ruby
result = Ractor.new do
  heavy_task()
end.value
```

You can wait for the termination of a Ractor with `Ractor#join` like this:

```ruby
Ractor.new do
  some_task()
end.join
```

`#value` and `#join` are similar to `Thread#value` and `Thread#join`.

To implement `#join`, `Ractor#monitor` (and `Ractor#unmonitor`) is introduced.

This commit changes `Ractor.select()` method.
It now only accepts ports or Ractors, and returns when a port receives a message or a Ractor terminates.

We removes `Ractor.yield` and `Ractor#take` because:
* `Ractor::Port` supports most of similar use cases in a simpler manner.
* Removing them significantly simplifies the code.

We also change the internal thread scheduler code (thread_pthread.c):
* During barrier synchronization, we keep the `ractor_sched` lock to avoid deadlocks.
  This lock is released by `rb_ractor_sched_barrier_end()`
  which is called at the end of operations that require the barrier.
* fix potential deadlock issues by checking interrupts just before setting UBF.

https://bugs.ruby-lang.org/issues/21262
2025-05-31 04:01:33 +09:00
John Hawthorn
f483befd90 Add shape_id to RBasic under 32 bit
This makes `RBobject` `4B` larger on 32 bit systems
but simplifies the implementation a lot.

[Feature #21353]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2025-05-26 10:31:54 +02: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
Takashi Kokubun
53a27f114a
YJIT: Split the block on optimized getlocal/setlocal (#13282) 2025-05-12 09:03:46 -07:00
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
Takashi Kokubun
cbf9c088f8
YJIT: End the block after OPTIMIZE_METHOD_TYPE_CALL (#13245) 2025-05-05 13:35:28 -07:00
Samuel Williams
06a7b3c144
Only test on known good platforms. (#13123) 2025-04-17 16:19:05 +00:00
Samuel Williams
c4ae6cb500
Prefer th->ec for stack base/size. (#13101) 2025-04-17 13:21:51 +00:00
Naoto Ono
5adb2591da
Skip TestThreadInstrumentation#test_sleeping_inside_ractor on ModGC workflow (#12996)
TestThreadInstrumentation#test_sleeping_inside_ractor is a flaky and failing intermittently. Additionally, Launchable reported this test as a top flaky test. (Link: https://app.launchableinc.com/organizations/ruby/workspaces/ruby/insights/unhealthy-tests)

It failed only failed intermittently on ModGC workflow, so I'm gonna skip this test on ModGC workflow.
2025-03-27 21:22:38 +09:00
Nobuyoshi Nakada
8d6f153fba Manage skipping instance variable IDs in one place 2025-03-17 23:42:16 +09:00
Nobuyoshi Nakada
4a67ef09cc
[Feature #21116] Extract RJIT as a third-party gem 2025-02-13 18:01:03 +09:00
Takashi Kokubun
01db456196 Move Array#map to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
Hiroshi SHIBATA
a2dd471d9e
macOS 15 is the stable version today 2024-11-06 15:45:32 +09:00
Peter Zhu
77db37813a Fix indentation in test_after_gc_start_hook_with_GC_stress 2024-10-03 11:58:20 -04:00
Hiroshi SHIBATA
baac5376da
Use macos? helper 2024-09-11 18:13:01 +09:00
Satoshi Tagomori
19ec803179 Reset the counter for two consecutive runs 2024-07-31 10:59:51 +09:00
Satoshi Tagomori
6c5c30b542 Use tmpdir for various environments (including Windows) 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
50a0552bd7 Fix test code and extension to avoid using gvars and Kernel methods 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
c884db0b5b [BUG #20655] Add tests to use rb_ensure and call cont.call 2024-07-30 15:31:24 +09:00
Kevin Newton
1c81d1a69d [PRISM] Refactor parser support into its own module 2024-07-18 21:15:54 -04:00
Kevin Newton
76ea5cde2a Refactor RUBY_DESCRIPTION assertions in test_rubyoptions 2024-07-18 13:03:17 -04:00
Hiroshi SHIBATA
371055979f Pend some tests because these are not working with macOS 15 beta and Xcode 16 beta 2024-07-12 13:38:22 +09:00
Jean Boussier
83f57ca3d2 String.new(capacity:) don't substract termlen
[Bug #20585]

This was changed in 36a06efdd9f0604093dccbaf96d4e2cb17874dc8 because
`String.new(1024)` would end up allocating `1025` bytes, but the problem
with this change is that the caller may be trying to right size a String.

So instead, we should just better document the behavior of `capacity:`.
2024-06-19 15:11:07 +02:00
tompng
04467218ce Add rb_str_resize coderange test 2024-06-13 18:27:02 +02:00
Nobuyoshi Nakada
e323dbb1bd
Make subclasses to define methods 2024-06-07 00:50:30 +09:00
Jean Boussier
730e3b2ce0 Stop exposing rb_str_chilled_p
[Feature #20205]

Now that chilled strings no longer appear as frozen, there is no
need to offer an API to check for chilled strings.

We however need to change `rb_check_frozen_internal` to no
longer be a macro, as it needs to check for chilled strings.
2024-06-02 13:53:35 +02:00
Jean Boussier
0b38403328 Fix incorrect assertion in TestThreadInstrumentation
The test meant to assert the thread is suspended at least once,
but was actually asserting to it to be suspected at least twice.
2024-05-20 14:59:59 +09:00
Étienne Barrié
2b08406cd0 Expose rb_str_chilled_p
Some extensions (like stringio) may need to differentiate between
chilled strings and frozen strings.

They can now use rb_str_chilled_p but must check for its presence since
the function will be removed when chilled strings are removed.

[Bug #20389]

[Feature #20205]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-26 12:54:54 +01:00
Jean Boussier
09d8c99cdc Ensure test suite is compatible with --frozen-string-literal
As preparation for https://bugs.ruby-lang.org/issues/20205
making sure the test suite is compatible with frozen string
literals is making things easier.
2024-03-14 17:56:15 +01:00
Thomas Marshall
7e4b1f8e19
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding
The documentation for `rb_enc_interned_str_cstr` notes that `enc` can be
a null pointer, but this currently causes a segmentation fault when
trying to autoload the encoding. This commit fixes the issue by checking
for NULL before calling `rb_enc_autoload`.
2024-03-03 10:43:35 +00:00