summaryrefslogtreecommitdiff
path: root/coroutine
AgeCommit message (Collapse)Author
2025-01-10coroutine/ppc64le: fix conditional registers got clobbered unexpectedlyliushuyu
Now we also save the special cr registers during the fiber switching Notes: Merged: https://github.com/ruby/ruby/pull/12535
2025-01-03Win32: Define COROUTINE_DECL to suppress a warningNobuyoshi Nakada
In cont.c: ``` warning C4141: 'noreturn': used more than once ``` Notes: Merged: https://github.com/ruby/ruby/pull/12501
2024-12-17Win32: Add coroutine for mswin on arm64Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12367
2024-12-17Fix coroutine implementaion on Windows-Arm64Lars Kanis
When setjmp/longjmp/exceptions are used on Windows it's necessary to store+restore additional information from the TEB. I didn't find any official documentation about the values to be saved, but found the corresponding boost/context implemenataion: https://github.com/boostorg/context/commit/abf8e04e23cf05a499594e674d1c90db39117662 This is similar to the special TIB handling on x86/x86_64 on Windows. Without this fix an exception in a fiber segfaults without any output: ruby -e "Fiber.new{ raise 'test' }.resume" Notes: Merged: https://github.com/ruby/ruby/pull/12363
2024-10-08Substitute `coroutine_transfer` with prefixed symbol in MakefileNobuyoshi Nakada
``` coroutine/arm64/Context.S:31:57: error: invoking macro TOKEN_PASTE argument 1: empty macro arguments are undefined in ISO C90 [-Wpedantic] 31 | .global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer) | ^ ```
2024-10-08Cast via `uintptr_t` function pointer between object pointerNobuyoshi Nakada
- ISO C forbids conversion of function pointer to object pointer type - ISO C forbids conversion of object pointer to function pointer type
2024-08-22Don't emit ELF notes on non-ELF platformsKJ Tsanaktsidis
These apparently break compilation on old MacOS toolchains, because the MachO section name is capped to 16 chars (although, on my MacOS, at least, the section name just gets truncated). Nevertheless, these serve no purpose on non-ELF platforms (they're part of the LSB Linux ABI). [Bug #20677] Notes: Merged: https://github.com/ruby/ruby/pull/11405
2024-08-22Fix typo in ELF note generationKJ Tsanaktsidis
This wasn't looking at the right macro name for pac-ret support, so if Ruby was compiled with pac-ret but NOT BTI, then the ELF note would not be emitted. Notes: Merged: https://github.com/ruby/ruby/pull/11405
2024-07-07Do not define SHSTK feature for amd64 Context.SKJ Tsanaktsidis
We do not implement CET shadow-stack switching in amd64 Context.S. If you compile Ruby with `-fcf-protection=full` and run it with `GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK` exported, it will crash with a control flow exception. Configure the appropriate notes at the end of Context.S [Bug #18061]
2024-07-07Revert autoconf macros defining RUBY_AARCH64_{BTI|PAC}_ENABLEDKJ Tsanaktsidis
This partially reverts https://github.com/ruby/ruby/pull/10944; now that we decided to pass CFLAGS to $(CC) when assembling .S files, we don't need these autoconf macros that capture the state of __ARM_FEATURE{PAC|BTI}_DEFAULT. [Bug #20601]
2024-07-04Use `__CET__` macro to enable IBT support. (#11081)Vít Ondruch
According to the GCC documentation [1], the macro `__CET__` is dfined when `-fcf-protection` compiler option is used. Therefore use this macro to enable IBT support instead of special casing for `__OpenBSD__`. [1]: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fcf-protection
2024-06-13Use ENDBR instruction in amd64 coroutine on OpenBSDJeremy Evans
When running on newer Intel processors supporting the feature, OpenBSD enforces indirect branch tracking. Without this endbr64 instruction, jumps to the coroutine_transfer function result in SIGILL on OpenBSD/amd64 when using such processors. The OpenBSD Ruby ports have been using a patch similar to this for the past two months. From some research, cet.h has been supported by GCC for about 6 years and LLVM for about 4 years.
2024-06-11Extract hardening CFLAGS to a special $hardenflags variableKJ Tsanaktsidis
This changes the automatic detection of -fstack-protector, -D_FORTIFY_SOURCE, and -mbranch-protection to write to $hardenflags instead of $XCFLAGS. The definition of $cflags is changed to "$hardenflags $orig_cflags $optflags $debugflags $warnflags" to match. Furthermore, these flags are _prepended_ to $hardenflags, rather than appended. The implications of doing this are as follows: * If a CRuby builder specifies cflags="-mbranch-protection=foobar" at the ./configure script, and the configure script detects that -mbranch-protection=pac-ret is accepted, then GCC will be invoked as "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". Since the last flags take precedence, that means that user-supplied values of these flags in $cflags will take priority. * Likewise, if a CRuby builder explicitly specifies "hardenflags=-mbranch-protection=foobar", because we _prepend_ to $hardenflags in our autoconf script, we will still invoke GCC as "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". * If a CRuby builder specifies CFLAGS="..." at the configure line, automatic detection of hardening flags is ignored as before. * C extensions will _also_ be built with hardening flags now as well (this was not the case by default before because the detected flags went into $XCFLAGS). Additionally, as part of this work, I changed how the detection of PAC/BTI in Context.S works. Rather than appending the autodetected option to ASFLAGS, we simply compile a set of test programs with the actual CFLAGS in use to determine what PAC/BTI settings were actually chosen by the builder. Context.S is made aware of these choices through some custom macros. The result of this work is that: * Ruby will continue to choose some sensible defaults for hardening options for the C compiler * Distributors are able to specify CFLAGS that are consistent with their distribution and override these defaults * Context.S will react to whatever -mbranch-protection is actually in use, not what was autodetected * Extensions get built with hardening flags too. [Bug #20154] [Bug #20520]
2024-03-05[DOC] fix some commentscui fliter
Signed-off-by: cui fliter <[email protected]>
2024-02-11Win32: Use prototypeNobuyoshi Nakada
2024-02-06Use `__asm` instead of `asm`Nobuyoshi Nakada
With `--std=c99` option coroutine/arm64/Context.h errs: ``` In file included from cont.c:26: coroutine/arm64/Context.h:59:5: error: call to undeclared function 'asm'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 59 | asm ("hint #8;" : "+r"(r17) : "r"(r16)); | ^ ``` Also move the common function header.
2024-01-29wasm: align fiber stack pointer to 16 bytesYuta Saito
In WebAssembly C ABI, the linear stack pointer must be always aligned to 16 bytes like other archs. The misaligned stack pointer causes some weird memory corruption since compiler assumes the aligned stack pointer.
2023-12-22coroutine/arm64: Skip saving/restoring x30 twice and use `autiasp`Yuta Saito
We don't need to save/restore x30 twice, and we can just use `ret`, which uses x30 as return address register instead of explicit `ret <reg>` instruction. This also allows us to use `autiasp` instead of `autia1716` and we can skip setting SP/LR to x16/x17. Also the size of register save area is shrunk by 16 bytes due to the removal of extra x30 save/restore.
2023-12-22coroutine/arm64/Context.S: Append PAC/BTI note section if neededYuta Saito
Fixes https://bugs.ruby-lang.org/issues/20029
2023-12-22coroutine/arm64/Context.S: Insert `bti c` as BTI landing padYuta Saito
2023-12-22coroutine/arm64: Sign return address if PAC enabledYuta Saito
2023-11-05Do not use non-ASCII chars in sourcesNobuyoshi Nakada
No encodings are guaranteed in C compilers, and other than UTF-8 encodings may be assumed in some platforms, e.g., CP932 on Windows Japanese edition, and may result in compilation errors.
2023-08-25Avoid memory dependency between instructions. (#8284)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2023-02-22Add support for LoongArch (#7343)小MAO钓鱼
* vm_dump.c: Dump machine registers on loongarch64 Linux. * coroutines: Support for native loongarch64 coroutines. --------- Co-authored-by: zangruochen <[email protected]> Notes: Merged-By: nurse <[email protected]>
2022-10-19Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)Sergey Fedorov
Notes: Merged-By: ioquatix <[email protected]>
2022-05-25Add support for address sanitizer for amd64 and arm64.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5926
2022-05-22Ruby31: add support for Darwin ppc/ppc64 (#5927)Sergey Fedorov
* add coroutines for ppc & ppc64 * fix universal coroutine to include ppc & ppc64 * add powerpc*-darwin to configure.ac * fix thread_pthread for older systems Notes: Merged-By: ioquatix <[email protected]>
2022-01-19[wasm] add coroutine/asyncify implementationYuta Saito
set the default coroutine_type as asyncify when wasi Notes: Merged: https://github.com/ruby/ruby/pull/5407
2021-07-02Ignore dead threads in `coroutine_join`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4620
2021-07-01Replace copy coroutine with pthread implementation.Samuel Williams
2021-05-04Fix -Wundef warnings in coroutine/*/Context.hBenoit Daloze
* See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/4428
2021-04-01coroutine: Darwin on ARM64 needs alignment of 2^2David CARLIER
2021-03-30Support for native riscv64 coroutines.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4337
2021-03-22coroutine mac m1 update.David CARLIER
using proper link register and frame pointer which equal x30/x29. Notes: Merged: https://github.com/ruby/ruby/pull/4243
2021-03-05Generating note.GNU-stack section for FreeBSD on x86.David Carlier
Not enabling for ELF in general as not all platform support it (e.g. NetBSD, implictly stack never executable). Notes: Merged: https://github.com/ruby/ruby/pull/4239
2021-03-05coroutine arm64 generating note.GNU-stack section for linux.David Carlier
Notes: Merged: https://github.com/ruby/ruby/pull/4238
2021-01-23coroutine/emscripten/: Experimentally support emscripten fiber APIYusuke Endoh
2021-01-22Support coroutine on universal binaryNobuyoshi Nakada
2021-01-22Added include guards to coroutine headersNobuyoshi Nakada
2020-12-08Fix "Ruby is not properly fortified on armv7hl".Samuel Williams
See <https://bugs.ruby-lang.org/issues/16762> for more details. Notes: Merged: https://github.com/ruby/ruby/pull/3866
2020-12-05Protoized old pre-ANSI K&R style definitionsNobuyoshi Nakada
2020-12-05Proposed method for dealing with stack locals which have non-local lifetime.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3624
2020-12-05Rework the order of operations to avoid stack smashing.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3624
2020-07-05Prefix export symbol prefix to coroutine_transferNobuyoshi Nakada
2020-07-05Removed trailing spaces [ci skip]Nobuyoshi Nakada
2020-04-01Patch assembly so that it aligns properlyPaul Jordan
Notes: Merged: https://github.com/ruby/ruby/pull/2995
2020-02-06function pointers are not void*卜部昌平
The same as 8427fca49bd85205f5a8766292dd893f003c0e48. Notes: Merged: https://github.com/ruby/ruby/pull/2885
2019-12-28Remove "All Rights Reserved." from Copyright statement.Samuel Williams
2019-12-28Remove "All Rights Reserved." from Copyright statement.Samuel Williams
2019-12-27Fix coroutine copy implementation on OpenBSDJeremy Evans
OpenBSD is the only platform that uses this support by default, and it did not work because while OpenBSD supports alloca, it does not include alloca.h. This should be backported to Ruby 2.7. From George Koehler