527 Commits
Author SHA1 Message Date
Samuel Williams b92c8c2253 Guard fiber target across fiber_store. (#17951)
Fixes [Bug #22196].
2026-07-18 13:08:53 +09:00
Samuel Williams 44d5a6fce4 Revert "Guard fiber target across fiber_store. (#17951)"
This reverts commit e377cd5e8e.
2026-07-17 21:18:57 +12:00
Samuel Williams e377cd5e8e Guard fiber target across fiber_store. (#17951)
Fixes [Bug #22196].
2026-07-17 16:17:32 +12:00
nagachika 148f263a0d merge revision(s) dc1777d017: [Backport #21955]
[PATCH] Ensure fiber stack is freed in all cases, if the fiber is terminated. (#16416)

	[Bug #21955]
2026-05-23 13:37:50 +09:00
刘皓 17877eb248 Backport WASI setjmp handler memory leak fixes to Ruby 3.4 (#14788)
[Bug #21626]
2025-10-09 07:30:42 -07:00
Nobuyoshi Nakada 51d3f6459b [DOC] Hide Fiber::Pool
It is experimental yet and is disabled currently.
2024-12-25 11:25:03 +09:00
Nobuyoshi Nakada adad97a031 [Bug #20978] Stringize Fiber storage keys 2024-12-23 18:16:28 +09: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
Nobuyoshi Nakada d07aa670b4 Get rid of duplicate modifier for MSVC 2024-12-18 21:49:37 +09:00
Nobuyoshi Nakada 42b1eaf234 Mark fiber_entry no-return 2024-11-27 10:47:40 +09:00
Kunshan Wang 8ae7c22972 Annotate anonymous mmap
Use PR_SET_VMA_ANON_NAME to set human-readable names for anonymous
virtual memory areas mapped by `mmap()` when compiled and run on Linux
5.17 or higher.  This makes it convenient for developers to debug mmap.
2024-11-21 13:48:05 -05:00
Yusuke Endoh ac5ac48a36 Revert 28a1c4f33e
28a1c4f33e seems to call an improper
ensure clause. [Bug #20655]
Than fixing it properly, I bet it would be much better to simply revert
that commit. It reduces the unneeded complexity. Jumping into a block
called by a C function like Hash#each with callcc is user's fault.
It does not need serious support.
2024-07-30 15:31:24 +09:00
Peter Zhu 214811974b Add ruby_mimcalloc
Many places call ruby_mimmalloc then MEMZERO. This can be reduced by
using ruby_mimcalloc instead.
2024-04-24 15:30:43 -04:00
Samuel Williams 6ade36c06b Fiber#raise recursively raises on nested resuming_fiber. (#10482)
* Improve consistency of `Fiber.current.raise`.
2024-04-17 23:08:47 +12:00
Samuel Williams 5d1702e01a Enumerator should use a non-blocking fiber, change rb_fiber_new to be non-blocking by default. (#10481) 2024-04-08 00:49:01 +12:00
Samuel Williams b473d304d4 Revert "Enumerator should use a non-blocking fiber. (#10478)" (#10480)
This reverts commit dfa0897de8.

This commit accidentally included some change in `parse.h`. Reverting
and re-applying the relevant changes.
2024-04-07 10:20:22 +00:00
Samuel Williams dfa0897de8 Enumerator should use a non-blocking fiber. (#10478) 2024-04-07 19:18:09 +12:00
KJ Tsanaktsidis 69579ed57a Mark fiber stacks in rb_execution_context_mark
Currently, fiber stacks are marked separately from the rest of the
execution context. The fiber code deliberately does _NOT_ set
ec->machine.stack_end on the saved EC, so that the code in
`rb_execution_context_mark` does not mark it; instead, the stack marking
is done in `cont_mark`.

Instead, we can set ec->machine.stack_end, and skip out on doing the
stack marking separately in `cont_mark`; that way, all machine stack
marking shares the same code (which does the nescessary ASAN things).

[Bug #20310]
2024-03-25 14:57:04 +11:00
Jean Boussier 8a8df49174 Update set_backtrace documentation
Followup: https://github.com/ruby/ruby/pull/10017

[Feature #13557]
2024-03-18 08:55:46 +01:00
KJ Tsanaktsidis 5621d794a2 Disable callcc when ASAN is enabled
callcc's implementation is fundamentally incompatible with ASAN. Since
callcc is deprecated and almost never used, it's probably OK to disable
callcc when ruby is compiled with ASAN.

[Bug #20273]
2024-03-04 13:07:26 +11:00
Nobuyoshi Nakada c30b8ae947 Adjust styles and indents [ci skip] 2024-01-08 00:50:41 +09:00
John Hawthorn f1b7424cbe FREE_AT_EXIT: Don't free main stack post-fork
When a forked process was started in a thread, this would result in a
double-free during the child process exit.

    RUBY_FREE_AT_EXIT=1 ./miniruby -e 'Thread.new { fork { } }.join; Process.waitpid'

This is because the main thread in the forked process was not the
initial VM thread, and the new thread's stack was freed as part of
objectspace iteration.

This change also allows rb_threadptr_root_fiber_release to run without
EC being available.
2023-12-22 18:07:22 -08:00
Victor Shepelev 07734b51c6 [DOC] Small fixes for documentation rendering
Mostly just fixing RDoc's incorrect treatment of `+`
2023-12-09 13:54:33 +09:00
Benoit Daloze 0204523fe7 Improve Fiber#kill docs and simplify the NEWS entry to let the documentation explain 2023-12-08 13:59:40 +01:00
6816e8efcf Free everything at shutdown
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2023-12-07 15:52:35 -05:00
Takashi KokubunandAlan Wu ba1cdadfc8 YJIT: Cancel on-stack jit_return on invalidation (#9086)
* YJIT: Cancel on-stack jit_return on invalidation

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>

* Use RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P

---------

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2023-11-30 21:35:55 -05:00
Takashi Kokubun 985370406d Call rb_jit_cont_init() even earlier
To fix https://github.com/ruby/ruby/actions/runs/6581593578/job/17881779994
2023-10-19 17:12:09 -07:00
Takashi Kokubun a9d7525fb4 Avoid initializing jit_cont_lock multiple times
Contrary to my initial assumption, rb_threadptr_root_fiber_setup() is
called for each Ractor, not just once at boot. I changed the place to
call rb_jit_cont_init() to avoid calling it multiple times.
2023-10-19 17:06:23 -07:00
Takashi Kokubun 6beb09c2c9 YJIT: Add RubyVM::YJIT.enable (#8705) 2023-10-19 10:54:35 -07:00
Samuel Williams d4c720a91b Fix support for dynamic keys. (#8273)
* Skip RBS test.
2023-08-24 15:19:33 +12:00
Nobuyoshi Nakada 5336b2f0db Move a local variable declaration after the protected region 2023-08-03 13:43:04 +09:00
Samuel Williams be86767eef Add VM_ASSERT on fiber->blocking == 0. (#7926)
I have not seen any problems with this code, but this ensures the invariant.
2023-06-10 23:13:01 +09:00
Samuel Williams 492e0025fd Allow environment variable to control madvise advice. (#7855)
Introduce experimental support for explicitly specifying the `advice` value provided to `madvise` when releasing the fiber stack.
2023-05-25 11:17:49 +09:00
Samuel Williams 2df5a697e2 Add Fiber#kill, similar to Thread#kill. (#7823) 2023-05-18 23:33:42 +09:00
Takashi Kokubun e07e9f8491 RJIT: Do nothing on jit_cont_free
if cont is NULL.
2023-03-09 22:31:51 -08:00
Takashi Kokubun f5909ac6d9 RJIT: Stop allowing leaked globals rjit_* 2023-03-08 23:24:38 -08:00
Takashi Kokubun 23ec248e48 s/mjit/rjit/ 2023-03-06 23:44:01 -08:00
Nobuyoshi Nakada ef00c6da88 Adjust else style to be consistent in each files [ci skip] 2023-02-26 13:20:43 +09:00
Samuel Williams f94e83faa0 Assigning nil to fiber storage deletes the association. (#7378)
Also avoid allocations when looking up `Fiber#storage` if not needed.
2023-02-25 19:27:11 +13:00
Matt Valentine-House 72aba64fff Merge gc.h and internal/gc.h
[Feature #19425]
2023-02-09 10:32:29 -05:00
zverok c621c6140a Docs: Fix problems with Fiber's docs
* References to Scheduler (was outdated to SchedulerInterface)
* References between new methods (storage, [], []=)
* Storage's call-sequence (rendered confusingly)
2022-12-23 18:09:49 +02:00
Nobuyoshi Nakada 9f42ee3e52 [DOC] Fix formatting 2022-12-21 14:34:40 +09:00
Benoit Daloze 33debffdd3 Use "Fiber storage variables" consistently 2022-12-20 23:05:56 +01:00
Benoit Daloze 4495dea153 Improve documentation for fiber-scoped variables
* Especially around Enumerator.
2022-12-20 23:05:56 +01:00
Benoit Daloze 0efa36ac06 Ensure Fiber storage is only accessed from the Fiber it belongs to 2022-12-20 19:32:23 +01:00
Benoit Daloze d557f17974 Use an experimental warning for Fiber#storage= 2022-12-20 19:32:23 +01:00
Benoit Daloze 45175962a6 Never use the storage of another Fiber, that violates the whole design
* See https://bugs.ruby-lang.org/issues/19078#note-30
2022-12-20 19:32:23 +01:00
Samuel Williams 6073782627 Disable SEH workaround on __MINGW64__ only. (#6957) 2022-12-19 13:45:50 +13:00
Samuel Williams 22d391dc63 Add spec for fiber storage. (#6896) 2022-12-10 13:54:53 +13:00
Samuel Williams 0436f1e15a Introduce Fiber#storage for inheritable fiber-scoped variables. (#6612) 2022-12-01 23:00:33 +13:00