Граф коммитов

507 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada cdf25cad6b Fix compilation error with `RB_EXPERIMENTAL_FIBER_POOL` 2022-03-18 00:42:15 +09:00
S-H-GAMELINKS f27770679f [DOC]Fix FreeBSD Bugzilla link 2022-03-15 09:23:57 +09:00
Nobuyoshi Nakada 2af8b04eca
Fix conversion macro for `size_t` 2022-03-13 21:10:33 +09:00
Nobuyoshi Nakada e081f333fe
Fix experimental Fiber::Pool definition
Toplevel `Pool` is too generic, and `struct fiber_pool` does not
seem compatible with `rb_fiber_t`.
2022-03-13 21:09:17 +09:00
Nobuyoshi Nakada d650b17686
`rb_fiber_terminate` must not return [Bug #18497]
In a forked process from a fiber, the fiber becomes the only
fiber, `fiber_switch` does nothing as there is no other fibers,
`rb_fiber_terminate` does not terminate the fiber.  In that case,
reaches the end of `fiber_entry` finaly, which is declared as
"COROUTINE" and should never return.
2022-01-19 19:57:16 +09:00
Nobuyoshi Nakada 069cca6f74
Negative RBOOL usage 2022-01-01 17:02:04 +09:00
Samuel Williams 02a9a72f43 Tidy up fiber scheduler interface documentation for `address_resolve` and `timeout_after`. 2021-12-21 17:22:55 +13:00
Samuel Williams 711342d935 Update cont.c 2021-12-21 12:32:54 +13:00
zverok eae5a34be3 Add SchedulerInterface#timeout_after and #address_resolve docs 2021-12-21 12:32:54 +13:00
zverok 224dfb2d6e Document Fiber::SchedulerInterface#io_read and #io_write 2021-12-21 12:32:54 +13:00
Nobuyoshi Nakada 12fbdf4d4e
Fix conflicting declaration on Solaris
SunC
```
"cont.c", line 24: identifier redeclared: madvise
	current : function(pointer to char, unsigned int, int) returning int
	previous: function(pointer to void, unsigned int, int) returning int : "/usr/include/sys/mman.h", line 232
```

GCC
```
cont.c:24:12: error: conflicting types for 'madvise'
   24 | extern int madvise(caddr_t, size_t, int);
      |            ^~~~~~~
In file included from cont.c:16:
/usr/include/sys/mman.h:232:12: note: previous declaration of 'madvise' was here
  232 | extern int madvise(void *, size_t, int);
      |            ^~~~~~~
```
2021-11-30 09:10:58 +09:00
Naohisa Goto 8287d2f23c Workaround for implicit declaration of function 'madvise' on Solaris
On Solaris, madvise(3C) is NOT defined for SUS (XPG4v2) or later,
but MADV_* macros are defined when __EXTENSIONS__ is defined.
This may cause compile error on Solaris 10 with GCC when
"-Werror=implicit-function-declaration" and "-D_XOPEN_SOURCE=600"
are added by configure.
2021-11-30 00:03:04 +09:00
卜部昌平 90f2ab9d62 rb_fiber_raise(): add doxygen
Must not be a bad idea to improve documents.
2021-09-30 20:55:23 +13:00
Samuel Williams 88ba5fe547 Expose `rb_fiber_raise` and tidy up the internal implementation. 2021-09-20 18:30:51 +12:00
Nobuyoshi Nakada 9c5ad5d42d
Suppress format-pedantic warnings 2021-09-02 08:47:47 +09:00
Nobuyoshi Nakada 28d03ee776 Remove root_jmpbuf in rb_thread_struct
It has not been used since 1b82c877df.
2021-08-10 19:08:38 +09:00
S-H-GAMELINKS ac7986f46a Remove unneeded rb_fiber_transfer_kw declaration 2021-08-07 17:18:20 +12:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
Nobuyoshi Nakada ab37e6ee7e
Adjust styles [ci skip]
* --procnames-start-lines
2021-07-18 19:55:07 +09:00
Kazuki Yamaguchi 4885c44bca cont.c: fix formatting of RDoc for Fiber class 2021-07-17 13:37:41 +09:00
Samuel Williams 42130a64f0
Replace copy coroutine with pthread implementation. 2021-07-01 11:23:03 +12:00
nagachika 8366506de1 cont.c: Replace "iff" with "if and only if" 2021-06-12 20:15:08 +09:00
Nobuyoshi Nakada 93be7a4c6b
Suppress clobbered warnings on Travis-CI ppc64le-linux 2021-06-03 20:07:26 +09:00
Samuel Williams dc25412042 Expose `rb_fiber_transfer` and `rb_fiber_transfer_kw`. 2021-06-03 20:47:31 +12:00
Ryuta Kamizono 33f2ff3bab Fix some typos by spell checker 2021-04-26 10:07:41 +09:00
Samuel Williams 92449e0e99 Fix handling of timeout accessing scheduler outside of non-blocking context. 2021-03-30 18:38:42 +13:00
David CARLIER 875c85a8bd fiber context update for Mac OS.
it is more about memory accounting sake. At allocation time,
 we make clear we re possibly reusing regions marked as reusable.
Noted also calls might not necessarily succeed at first so we do
 only when necessary.
2021-03-29 09:32:40 +13:00
David Carlier 5e16c3a12a solaris/illumos build fix. 2021-03-22 22:51:15 +09:00
Kazuhiro NISHIYAMA ad0fa53203
[DOC] some methods of Fiber do not need to require anymore [Feature #17407] 2021-03-22 18:59:25 +09:00
Nobuyoshi Nakada d91ade3e1e
Renamed functions for Fiber singleton methods 2021-03-12 18:15:56 +09:00
Nobuyoshi Nakada 90c12defb3
Constified variables for getenv 2021-03-12 17:13:53 +09:00
Nobuyoshi Nakada 9d8c66fd6a
rb_fiber_terminate never returns 2021-02-24 04:09:57 +09:00
nicholas a. evans 3ee4fa9491
Send :fiber_switch event for almost every fiber_switch (#4207)
With this patch, TracePoint receives a `:fiber_switch` event for
_almost_ every fiber switch.  Previously, it would not be sent when an
exception was going to be raised. Now the event should only be blockable
by an interrupt (including `Thread#raise`) or a fatal error.

Additionally, interrupts will now be checked on the return fiber
_before_ re-raising the terminating unhandled exception.  And a fiber
that terminates with an unhandled exception no longer creates a pending
interrupt on its thread.  The exception will be raised in the return
fiber the same way as `Fiber#raise`: using `cont.value` with `cont.argc
== -1`

I moved `rb_exc_raise` from `fiber_store` to the end of `fiber_switch`
after _all_ of the other cleanup code: `fiber_stack_release`,
`th->blocking` increment, `RUBY_VM_CHECK_INTS`, and `EXEC_EVENT_HOOK`.
It seems to me that skipping those other cleanup steps may have also
resulted in other bugs.
2021-02-22 10:33:11 +13:00
Samuel Williams 5f69a7f604
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`.

* Use public interface if available.

* Use `rb_check_funcall` where possible.

* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00
Nobuyoshi Nakada 521ad9a13a Moved Fiber methods into core [Feature #17407] 2021-01-13 23:20:02 +09:00
Marcus Stollsteimer 3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
Nobuyoshi Nakada 09aca50fc4
Adjusted styles [ci skip] 2020-12-28 19:52:14 +09:00
Marc-Andre Lafortune cf1f9bdc8d Language tweaks to Fiber [doc] 2020-12-27 16:09:06 -05:00
Kazuhiro NISHIYAMA 2c752ff930
Fix a typo [ci skip] 2020-12-24 23:13:36 +09:00
zverok 1415653c84 Redocument non-blocking Fibers and scheduler
* Document Fiber's method related to scheduling;
* Extend Fiber's class docs with concepts of non-blocking
  fibers;
* Introduce "imaginary" (documentation-only) class
  Fiber::SchedulerInterface to properly document how
  scheduler's methods should look.
2020-12-24 03:03:51 -05:00
zverok 24ae0e8ed7 Review comments 2020-12-24 14:37:09 +09:00
zverok 5696c69354 Redocument Fiber#transfer 2020-12-24 14:37:09 +09:00
Delton Ding c6d7e02b90 Enable `Fiber.current` and `Fiber#alive?` call inside ractor 2020-12-23 03:27:14 +09:00
Marc-Andre Lafortune d0050edb84 Update Fiber#backtrace doc [See bug #17408] 2020-12-21 21:07:13 -05:00
zverok 843fd1e8cf Document Fiber#backtrace and #backtrace_locations 2020-12-21 19:22:38 -05:00
nicholas a. evans 31e8de2920 Let Fiber#raise work with transferring fibers
This automatically choosess whether to use transfer on a transferring
fiber or resume on a yielding fiber.  If the fiber is resuming, it
raises a FiberError.
2020-12-12 10:18:19 +13:00
Takashi Kokubun 01f38693aa
Remove obsoleted internal/mjit.h inclusion
🙇
2020-11-22 20:28:34 -08:00
Takashi Kokubun e0156bd396
Make sure all threads are scanned on unload_units
This has been a TODO since 79df14c04b. While adcf0316d1 covered the
root_fiber of the initial thread, it didn't cover root_fibers of other
threads. Now it's hooked properly in rb_threadptr_root_fiber_setup.

With regards to "XXX: Is this mjit_cont `mjit_cont_free`d?", when
rb_threadptr_root_fiber_release is called, although I'm not sure when
th->root_fiber is truthy, fiber_free seems to call cont_free and
mjit_cont_free. So mjit_conts of root_fibers seem to be freed properly.
2020-11-21 19:36:55 -08:00
Koichi Sasada 5e3259ea74 fix public interface
To make some kind of Ractor related extensions, some functions
should be exposed.

* include/ruby/thread_native.h
  * rb_native_mutex_*
  * rb_native_cond_*
* include/ruby/ractor.h
  * RB_OBJ_SHAREABLE_P(obj)
  * rb_ractor_shareable_p(obj)
  * rb_ractor_std*()
  * rb_cRactor

and rm ractor_pub.h
and rename srcdir/ractor.h to srcdir/ractor_core.h
    (to avoid conflict with include/ruby/ractor.h)
2020-11-18 03:52:41 +09:00
Nobuyoshi Nakada 0d52dce3a3
strip trailing spaces and adjusted indents [ci skip] 2020-11-12 19:27:20 +09:00
Samuel Williams a08ee8330d Rename to `Fiber#set_scheduler`. 2020-11-07 23:39:50 +13:00
Kazuhiro NISHIYAMA 0714cb760c
Remove duplicated line [ci skip]
ref bf3b2a4374
2020-10-14 15:16:36 +09:00
Koichi Sasada bf3b2a4374 relax Fiber#transfer's restriction
Using Fiber#transfer with Fiber#resume for a same Fiber is
limited (once Fiber#transfer is called for a fiber, the fiber
can not be resumed more). This restriction was introduced to
protect the resume/yield chain, but we realized that it is too much
to protect the chain. Instead of the current restriction, we
introduce some other protections.

(1) can not transfer to the resuming fiber.
(2) can not transfer to the yielding fiber.
(3) can not resume transferred fiber.
(4) can not yield from not-resumed fiber.

[Bug #17221]

Also at the end of a transferred fiber, it had continued on root fiber.
However, if the root fiber resumed a fiber (and that fiber can resumed
another fiber), this behavior also breaks the resume/yield chain.
So at the end of a transferred fiber, switch to the edge of resume
chain from root fiber.
For example, root fiber resumed f1 and f1 resumed f2, transferred to
f3 and f3 terminated, then continue from the fiber f2 (it was continued
from root fiber without this patch).
2020-10-12 22:58:41 +09:00
Aaron Patterson 9fb60672d5 Fix a use-after-free bug reported by ASAN
If a fiber and thread are collected at the same time, the thread might
get collected first and the pointer on the fiber will go bad.  I don't
think we need to check whether or not this is the main fiber in order to
release its stack
2020-10-01 08:42:52 -07:00
Benoit Daloze 178c1b0922 Make Mutex per-Fiber instead of per-Thread
* Enables Mutex to be used as synchronization between multiple Fibers
  of the same Thread.
* With a Fiber scheduler we can yield to another Fiber on contended
  Mutex#lock instead of blocking the entire thread.
* This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby.
* [Feature #16792]
2020-09-14 16:44:09 +12:00
Samuel Williams 132453fa52 Rename `Fiber{}` to `Fiber.schedule{}`. 2020-09-14 16:44:09 +12:00
Koichi Sasada 79df14c04b Introduce Ractor mechanism for parallel execution
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.

[Feature #17100]

This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.

I hope this feature can help programmers from thread-safety issues.
2020-09-03 21:11:06 +09:00
Samuel Williams 0a218a97ad Expose ec -> backtrace (internal) and use it to implement fiber backtrace.
See <https://bugs.ruby-lang.org/issues/16815> for more details.
2020-08-18 00:56:35 +12:00
Samuel Williams 4bff8e8423 Ensure that the head of the vacancy list is correctly inserted into the linked list.
See <https://bugs.ruby-lang.org/issues/16814> for more details.
2020-06-05 11:40:59 +12:00
Jeremy Evans faab5cbeb7 Fix documentation for Fiber#raise [ci skip]
Fixes [Bug #16912]
2020-05-25 19:46:12 -07:00
Samuel Williams 0e3b0fcdba
Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada 5d430c1b34
Added more NORETURN declarations 2020-05-11 00:40:14 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Takashi Kokubun adcf0316d1
Prevent unloading methods used in root_fiber while calling another Fiber (#2939)
Fixing SEGVs like:
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400
2020-02-28 23:58:33 -08:00
Lourens Naudé 40c57ad4a1 Let execution context local storage be an ID table 2020-01-11 14:40:36 +13:00
Jeremy Evans beae6cbf0f Fully separate positional arguments and keyword arguments
This removes the warnings added in 2.7, and changes the behavior
so that a final positional hash is not treated as keywords or
vice-versa.

To handle the arg_setup_block splat case correctly with keyword
arguments, we need to check if we are taking a keyword hash.
That case didn't have a test, but it affects real-world code,
so add a test for it.

This removes rb_empty_keyword_given_p() and related code, as
that is not needed in Ruby 3.  The empty keyword case is the
same as the no keyword case in Ruby 3.

This changes rb_scan_args to implement keyword argument
separation for C functions when the : character is used.
For backwards compatibility, it returns a duped hash.
This is a bad idea for performance, but not duping the hash
breaks at least Enumerator::ArithmeticSequence#inspect.

Instead of having RB_PASS_CALLED_KEYWORDS be a number,
simplify the code by just making it be rb_keyword_given_p().
2020-01-02 18:40:45 -08:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Nobuyoshi Nakada db16629008
Fixed misspellings
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-20 09:32:42 +09:00
Nobuyoshi Nakada c688026455
Suppress strict-aliasing warning by x86_64-w64-mingw32-gcc 7.4.0 2019-11-28 10:53:26 +09:00
Kazuhiro NISHIYAMA cf377c5556
Fix a typo [ci skip] 2019-11-04 17:12:18 +09:00
卜部昌平 f5e4063272 ruby_mimmalloc can return NULL
malloc can fail.  Should treat such situations.
2019-11-01 16:58:19 +09:00
Aaron Patterson 6147fa82a9
Fix continuation mark / compact 2019-10-28 13:09:10 -07:00
Jeremy Evans aba23d83f2 Fix documentation for Fiber#transfer [ci skip]
Fiber#transfer prevents calling Fiber#resume on the receiver of the
transfer method, not the fiber calling transfer.

Transfering back to a fiber does not allow later calling resume on
the fiber.  Once transfer has been called on a fiber, you can never
call resume on the fiber.

Calling resume on a transferred fiber is not a double resume error,
it is a different FiberError (cannot resume transferred Fiber).

For details on the differences between transferred fibers and
regular fibers, see Sasada-san's RubyKaigi 2017 presentation (in
short, Fiber#transfer is for coroutine, Fiber#resume is for
semi-coroutine).
2019-10-26 18:41:35 -07:00
Koichi Sasada 38e931fa2c show "transferred" attribute on Fiber#to_s
If a fiber is invoked with transfer method (such as "f.transfer"),
then the invoked fiber ("f") is labeled as "transferred" and this
fiber can not be invoked with Fiber#resume. This patch adds
transferred attribute for "Fiber#to_s" (and inspect).
2019-10-24 16:46:21 +09:00
Koichi Sasada 4c3e3b8028 Revert "Fix Fiber#transfer"
This reverts commit fa8ac91e95.

Previous behavior is intentional.
2019-10-24 16:46:21 +09:00
Jeremy Evans fa8ac91e95
Fix Fiber#transfer
Fiber#transfer previously made it impossible to resume the fiber
if it was transferred to (no resuming the target of Fiber#transfer).
However, the documentation specifies that you cannot resume a fiber
that has transferred to another fiber (no resuming the source of
Fiber#transfer), unless control is transferred back.

Fix the code by setting the transferred flag on the current/source
fiber, and unsetting the transferred flag on the target fiber.

Fixes [Bug #9664]
Fixes [Bug #12555]
2019-10-21 16:54:58 -07:00
Jeremy Evans dd2068ac8d Add rb_adjust_argv_kw_splat to internal.h
We are calling this in a few other files, it is better to have it
in a header than adding prototypes to the other files.
2019-09-26 15:30:51 -07:00
Aaron Patterson f5e8d33761
Fix clang errors when pendantic errors enabled
I've been compiling with:

```
  set -lx cflags '-std=c99 -Werror=pedantic -pedantic-errors'
```

But compilation would fail with the following:

```
cont.c:296:90: error: format specifies type 'void *' but the argument has type 'struct fiber_pool_stack *' [-Werror,-Wformat-pedantic]
    if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %"PRIuSIZE"/%"PRIuSIZE"\n", stack, offset, stack->available);
                                                        ~~                               ^~~~~
cont.c:467:24: error: format specifies type 'void *' but the argument has type 'struct fiber_pool *' [-Werror,-Wformat-pedantic]
                count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size);
                       ^~~~~~~~~~
cont.c:588:83: error: format specifies type 'void *' but the argument has type 'struct fiber_pool_vacancy *' [-Werror,-Wformat-pedantic]
    if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", fiber_pool->vacancies, fiber_pool->used);
                                                          ~~                      ^~~~~~~~~~~~~~~~~~~~~
cont.c:736:76: error: format specifies type 'void *' but the argument has type 'rb_fiber_t *' (aka 'struct rb_fiber_struct *')
      [-Werror,-Wformat-pedantic]
    if (DEBUG) fprintf(stderr, "fiber_stack_release: %p, stack.base=%p\n", fiber, fiber->stack.base);
```

This commit just fixes the pedantic errors
2019-09-26 14:58:11 -07:00
Jeremy Evans b193041b99 Fix keyword argument separation issues in Fiber#resume 2019-09-26 08:01:53 -07:00
Jeremy Evans fd2ef1a9bf Add VM_NO_KEYWORDS
I think this is easier to read than using literal 0 with comments
in every case where it is used.
2019-09-05 17:47:12 -07:00
Yusuke Endoh ce04392d8d Propagate kw_splat information
The kw_splat flag is whether the original call passes keyword or not.
Some types of methods (e.g., bmethod and sym_proc) drops the
information.  This change tries to propagate the flag to the final
callee, as far as I can.
2019-09-05 17:47:12 -07:00
卜部昌平 bc3e7924bc rb_proc_new / rb_fiber_new now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST
wherever necessary.
2019-08-27 15:52:26 +09:00
卜部昌平 703783324c rb_ensure now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_ensure, which also revealed many arity / type mismatches.
2019-08-27 15:52:26 +09:00
Yusuke Endoh c5db4c28f9 cont.c: remove unused STACK_GROW_DIR_DETECTION
to suppress a waring for "unused variable"
2019-08-19 15:01:48 +09:00
Iain Barnett dce1e14e80 Use more different arguments in Fiber.yield documentation to make it clear (#2170)
https://github.com/ruby/ruby/pull/2170#issuecomment-489880700

Documentation is for those who don't know, remember, or understand (to any degree) the language, it should attempt to be clear above all other things. The example given is needlessly unclear because if you use a block it's common for arguments to be reused on every entry to the block. In Fiber's case this is not so.

First time round 10 goes in, 12 comes out.
Second time round 14 goes in, 14 comes out… was that because 14 is 12 + 2 or because it's "the return value of the call to Fiber.yield". It's the latter because it says so but why does the example need to make anyone think the former?

Using different numbers makes it immediately clear what's happening whether the description is there or not.
2019-08-17 14:24:45 +09:00
Aaron Patterson aac4d9d6c7
Rename rb_gc_mark_no_pin -> rb_gc_mark_movable
Renaming this function.  "No pin" leaks some implementation details.  We
just want users to know that if they mark this object, the reference may
move and they'll need to update the reference accordingly.
2019-08-12 16:44:54 -04:00
Kazuhiro NISHIYAMA 0f10828fcf
Fix a typo [ci skip] 2019-08-13 01:03:14 +09:00
Kazuhiro NISHIYAMA 968c7b4398
Fix unused variable 2019-07-29 23:05:00 +09:00
Nobuyoshi Nakada efa380b006
Use PRIuSIZE instead of "%zu" 2019-07-25 05:54:38 +09:00
Samuel Williams 0a7093a8e9
Add documentation to `fiber_pool_allocate_memory`. 2019-07-19 20:18:42 +12:00
Samuel Williams 517f7f9b57
Fix 32-bit build and typo.
"Therefore, `fiber_pool_stack_free(&vacancy->stack)` can do the wrong
thing..." should be "... `fiber_pool_stack_free(stack)` ...".
2019-07-19 20:09:03 +12:00
Samuel Williams e004afd46d
Ensure that madvise does not clobber vacancy data.
After calling `fiber_pool_vacancy_reset`, `vacancy->stack` and `stack` are
no longer in sync. Therefore, `fiber_pool_stack_free(&vacancy->stack)` can
do the wrong thing and clobber the vacancy data.

Additionally, when testing using VM_CHECK_MODE > 0, use MADV_DONTNEED if
possible, to catch issues w.r.t. clobbered vacancy data earlier.
2019-07-19 19:42:09 +12:00
Samuel Williams cf93f98a60
Better usage of `rb_ec_clear_vm_stack` to maintain invariants. 2019-07-19 15:46:56 +12:00
Samuel Williams 6eef80d824
Improve ec assertions. 2019-07-19 15:46:56 +12:00
Koichi Sasada 4ec5b39ce8 initialize only Fiber's cfp.
fiber->cont.saved_ec.cfp should be initialized by NULL
because no vm_stack is allocated. However, cont_init()
captures current Fiber's cfp for continuation, so it should
only initialize fibers.
2019-07-19 08:53:19 +09:00
Samuel Williams 8ca32020b0
Revert "Ensure cfp is initialized to NULL."
This reverts commit d7fdf45a4a.
2019-07-19 11:32:40 +12:00
Samuel Williams d7fdf45a4a
Ensure cfp is initialized to NULL.
`cont_init` didn't initialize `cont->saved_ec.cfp`. Calling `cont_mark`
would result in an invalid `cfp` in `rb_execution_context_mark`. Because
fibers lazy-initialize the stack, fibers that are created but not resumed
could cause this problem to occur.
2019-07-19 11:10:01 +12:00
Samuel Williams 9dda0a03cc
Remove `rb_vm_push_frame` as it is no longer used. 2019-07-19 11:10:01 +12:00