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

467 Коммитов

Автор SHA1 Сообщение Дата
Yusuke Endoh b3d8dddee7 Try to ignore a noisy ASAN warning for continuation 2022-09-20 22:25:05 +09:00
Peter Zhu efb91ff19b Rename rb_ary_tmp_new to rb_ary_hidden_new
rb_ary_tmp_new suggests that the array is temporary in some way, but
that's not true, it just creates an array that's hidden and not on the
transient heap. This commit renames it to rb_ary_hidden_new.
2022-07-26 09:12:09 -04:00
Aaron Patterson 1341dea771 Prevent the stack from being marked twice
This commit prevents the stack from being marked twice: once via the
Fiber, and once via the Thread.  It introduces an assertion to assert
that the ec on the thread is the same as the ec on the Fiber being
marked via the thread.
2022-07-20 13:45:55 -07:00
Yusuke Endoh 5060c9d852 cont.c: prevent a warning of GCC 12.1
... by assigning a dummy value to the allocated stack.

http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220613T000004Z.log.html.gz
```
cont.c: In function ‘cont_restore_0.constprop’:
cont.c:1489:28: warning: ‘*sp’ may be used uninitialized [-Wmaybe-uninitialized]
 1489 |                 space[0] = *sp;
      |                            ^~~
```

Also it adds some comments about the hack of dummy stack allocation.
2022-06-13 15:18:28 +09:00
Samuel Williams 2556e15d75 Remove unnecessary ignore warnings. 2022-05-26 16:51:53 +12:00
Samuel Williams 86602484a2 Ensure we retain the main fiber stack bounds. 2022-05-25 21:50:53 +12:00
Samuel Williams 9a8fc4e04c Tidy up redundant returns. 2022-05-25 15:24:24 +12:00
Samuel Williams 901525b107 Add support for address sanitizer for amd64 and arm64. 2022-05-25 15:24:24 +12:00
Peter Zhu 5f10bd634f Add ISEQ_BODY macro
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using
this macro will make it easier for us to change the allocation strategy
of rb_iseq_constant_body when using Variable Width Allocation.
2022-03-24 10:03:51 -04:00
Nobuyoshi Nakada f69a969544 Fix potential memory leak at fiber pool
Do not "allocate then wrap".  It leaks the allocated memory if
failed to create the wrapper.
2022-03-18 00:42:15 +09:00
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