Commit graph

23 commits

Author SHA1 Message Date
Alan Wu
08b3a45bc9 Push a real iseq in rb_vm_push_frame_fname()
Previously, vm_make_env_each() (used during proc
creation and for the debug inspector C API) picked up the
non-GC-allocated iseq that rb_vm_push_frame_fname() creates,
which led to a SEGV when the GC tried to mark the non GC object.

Put a real iseq imemo instead. Speed should be about the same since
the old code also did a imemo allocation and a malloc allocation.

Real iseq allows ironing out the special-casing of dummy frames in
rb_execution_context_mark() and rb_execution_context_update(). A check
is added to RubyVM::ISeq#eval, though, to stop attempts to run dummy
iseqs.

[Bug #21180]

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2025-03-12 15:00:26 -04:00
Samuel Williams
a8c2d5e7be
Ensure fiber scheduler re-acquires mutex when interrupted from sleep. (#12158)
[Bug #20907]
2024-11-23 23:54:12 +00:00
Samuel Williams
05aaff2191
Reduce number of iterations in TestFiberScheduler#test_autoload. (#8391)
`ppc64le` appears to be struggling with this test due to timeout. Let's see
if reducing the number of iterations can help improve the test performance.
2023-09-07 13:53:51 +12:00
Nobuyoshi Nakada
bb0ec7df32
Wait killed threads 2022-12-02 23:46:21 +09:00
Samuel Williams
7f175e5648
Avoid missed wakeup with fiber scheduler and Fiber.blocking. (#6588)
* Ensure that blocked fibers don't prevent valid wakeups.
2022-10-20 13:38:52 +13:00
Samuel Williams
765ee822b5
Add missing f.resume to fiber test. (#6539) 2022-10-13 19:04:06 +13:00
Samuel Williams
e696ec67ac
Introduce Fiber.blocking{} for bypassing the fiber scheduler. (#6498) 2022-10-06 23:00:49 +13:00
Samuel Williams
42bcc629fb Retain reference to blocking fibers. 2022-05-25 15:24:24 +12:00
Yusuke Endoh
df0bcb3385 test/fiber/test_scheduler.rb: Remove the test file from $LOADED_FEATURES
to prevent the following failure on `make test-all --repeat-count=2`

http://ci.rvm.jp/results/trunk-repeat20-asserts@phosphorus-docker/3957774
```
  1) Error:
TestFiberScheduler#test_autoload:
NameError: uninitialized constant TestFiberSchedulerAutoload
          Object.const_get(:TestFiberSchedulerAutoload)
                ^^^^^^^^^^
```
2022-05-09 10:20:25 +09:00
Samuel Williams
fd6cef79f5
Use a proper mutex for autoloading features. (#5788)
Object#autoload implements a custom per-thread "mutex" for blocking
threads waiting on autoloading a feature. This causes problems when used
with the fiber scheduler. We swap the implementation to use a Ruby mutex
which is fiber aware.
2022-05-08 10:22:58 +12:00
Samuel Williams
81d0ce7e97 Mark IO::Buffer as experimental. 2021-11-10 19:21:05 +13:00
Samuel Williams
050a895439
Wake up join list within thread EC context. (#4471)
* Wake up join list within thread EC context.

* Consume items from join list so that they are not re-executed.

If `rb_fiber_scheduler_unblock` raises an exception, it can result in a
segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This
change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC
which initially caused an infinite loop because on exception will retry. We
explicitly remove items from the thread's join list to avoid this situation.

* Verify the required scheduler interface.

* Test several scheduler hooks methods with broken `unblock` implementation.
2021-06-14 17:56:53 +12:00
Samuel Williams
92449e0e99 Fix handling of timeout accessing scheduler outside of non-blocking context. 2021-03-30 18:38:42 +13:00
Samuel Williams
a08ee8330d Rename to Fiber#set_scheduler. 2020-11-07 23:39:50 +13:00
Nobuyoshi Nakada
eef12cdc06
strip trailing spaces [ci skip] 2020-10-01 13:47:57 +09:00
Samuel Williams
13660105e2 Don't call Scheduler#close if it doesn't exist. 2020-10-01 16:02:03 +13:00
Samuel Williams
388281c5c9 Fix order of operations during rb_ec_finalize. 2020-09-30 16:34:38 +13:00
Nobuyoshi Nakada
b57c54679b
strip trailing spaces [ci skip] 2020-09-23 17:47:30 +09:00
Samuel Williams
501fff14c7 When setting current thread scheduler to nil, invoke #close. 2020-09-21 09:51:33 +12:00
Samuel Williams
132453fa52 Rename Fiber{} to Fiber.schedule{}. 2020-09-14 16:44:09 +12:00
Samuel Williams
d387029f39 Standardised scheduler interface. 2020-09-14 16:44:09 +12:00
Hiroshi SHIBATA
b2976a4fca
Fixup d48c92aa04 2020-05-23 17:24:29 +09:00
Hiroshi SHIBATA
d48c92aa04
Rename TestScheduler* to TestFiber for convention of the test directory 2020-05-23 16:44:57 +09:00
Renamed from test/fiber/test_fiber.rb (Browse further)