summaryrefslogtreecommitdiff
path: root/signal.c
AgeCommit message (Collapse)Author
3 daysFix jump buffer leak in WASI builds刘皓
Notes: Merged: https://github.com/ruby/ruby/pull/13142
6 daysDo not allocate new objects at machine stack overflowNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13167
2024-12-05Use rb_gc_enable/rb_gc_disable_no_rest instead of ruby_disable_gcPeter Zhu
We should use the rb_gc_enable/rb_gc_disable_no_rest APIs instead of directly setting the ruby_disable_gc variable. Notes: Merged: https://github.com/ruby/ruby/pull/12264
2024-09-26Import patches for old macOS from MacPortsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11690
2024-04-04Revert "hijack SIGCHLD handler for internal use"Nobuyoshi Nakada
This reverts commit 054a412d540e7ed2de63d68da753f585ea6616c3. SIGCHLD `waidpid`, `waitpid_lock` and related code, have been removed at ruby/ruby#7527.
2024-04-03Check if a fatal signal is from kernelNobuyoshi Nakada
On Linux, `siginfo_t` uses a union for each `si_code`, and the field corresponding to `si_pid` does not belong to the `_sigfault` field for SIGSEGV. It actually overlaps the `si_addr` field, which is usually non-zero on stack overflow. https://github.com/ruby/ruby/pull/10201#issuecomment-2034723244
2024-03-12Disregard si_addr for fatal signals sent from other processesPeter Zhu
Previously, when another process sends a fatal signals such as SIGBUS to Ruby, we could mis-interpret it as a stack overflow Ruby itself generated. When the si_pid field is set on the signal, we shouldn't check the si_addr field to check for stack overflow. > Signals sent with kill(2) and sigqueue(3) fill in si_pid and si_uid. Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-01-30Prefer `sa_handler` to `sa_sigaction` in WasmYusuke Endoh
Previously the code assigns `handler` function pointer, which accepts one argument, to `sigact.sa_sigaction`, which accepts three argument. This mismatch is not allowed in Wasm. I don't see the reason to use `sa_sigaction` here, so this change assigns to `sa_handler`, which accepts one argument, in Wasm.
2023-12-19signal.c: Fix undefined `reset_sigmask` use on EmscriptenYuta Saito
3c471149910d79745b50389c436f0ed2973e0d91 added a call to `reset_sigmask` but the guard condition didn't match with the condition used to define `reset_sigmask`.
2023-12-18Unmask signal before re-raising fatal signalAlan Wu
On Linux, while the signal handler runs, that signal is masked, so in the rb_bug_for_fatal_signal() code path we didn't get the default signal action as intended. See signal(7). It worked fine on macOS, though. Before: $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid' <snip> Aborted (core dumped) After: $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid' <snip> Segmentation fault (core dumped) Follow-up for 1ac0afab4da "rb_bug_for_fatal_signal: exit with the right signal".
2023-12-11Initialize interrupt queue before signal handlers (#9196)Takashi Kokubun
2023-07-19Reset signal handler before aborting due to sanitizerNobuyoshi Nakada
When aborting by a sanitizer, `SIGILL` or something is raised and often results in raising the same signal infinitely. Notes: Merged: https://github.com/ruby/ruby/pull/8090
2023-07-19Unify `writev` and `write` operations in `check_reserved_signal_`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8090
2023-07-17Move `posix_signal` declaration internal with prefix `ruby_`Nobuyoshi Nakada
2023-05-16Ensure SIGCHLD always uses a signal handler. (#7819)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-15Remove explicit SIGCHLD handling. (#7816)Samuel Williams
* Remove unused SIGCHLD handling. * Remove unused `init_sigchld`. * Remove unnecessary `#define RUBY_SIGCHLD (0)`. * Remove unused `SIGCHLD_LOSSY`. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-15Use the rb_sys_fail_str macro in signal.cKunshan Wang
Let signal.c include "internal/error.h" explicitly to ensure that the identifier rb_sys_fail_str in signal.c refers to the macro defined in "internal/error.h" instead of the actual function. That macro reads errno before evaluating its argument. Without this change, the rb_signo2signm(sig) expression in the "trap" function in signal.c will overwrite the errno before the actual rb_sys_fail_str function reads the errno. Notes: Merged: https://github.com/ruby/ruby/pull/7812
2023-03-15Remove SIGCHLD `waidpid`. (#7527)Samuel Williams
* Remove `waitpid_lock` and related code. * Remove un-necessary test. * Remove `rb_thread_sleep_interruptible` dead code. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-14Revert SIGCHLD changes to diagnose CI failures. (#7517)Samuel Williams
* Revert "Remove special handling of `SIGCHLD`. (#7482)" This reverts commit 44a0711eab7fbc71ac2c8ff489d8c53e97a8fe75. * Revert "Remove prototypes for functions that are no longer used. (#7497)" This reverts commit 4dce12bead3bfd91fd80b5e7195f7f540ffffacb. * Revert "Remove SIGCHLD `waidpid`. (#7476)" This reverts commit 1658e7d96696a656d9bd0a0c84c82cde86914ba2. * Fix change to rjit variable name. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-09Remove special handling of `SIGCHLD`. (#7482)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-09Remove SIGCHLD `waidpid`. (#7476)Samuel Williams
* Remove `waitpid_lock` and related code. * Remove un-necessary test. * Remove `rb_thread_sleep_interruptible` dead code. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-01-01[DOC] [Bug #19290] fix formattingNobuyoshi Nakada
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2021-09-06Use free instead of xfree to free altstackYusuke Endoh
The altstack memory of a thread may be free'ed even after the VM is destructed. After that, GC is no longer available, so calling xfree may lead to a segfault. This changeset uses the bare free function to free the altstack memory instead of xfree. [Bug #18126]
2021-08-18SIGILL can raise at stack overflow on Linux too [Bug #18084]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4751
2021-08-18Rewind execution tags more at stack overflow [Bug #18084]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4751
2021-05-04Fix -Wundef warnings for patterns `#if HAVE`Benoit Daloze
* See [Feature #17752] * Using this to detect them: git grep -P 'if\s+HAVE' | grep -Pv 'HAVE_LONG_LONG|/ChangeLog|HAVE_TYPEOF' Notes: Merged: https://github.com/ruby/ruby/pull/4428
2021-01-19Replace "iff" with "if and only if"Gannon McGibbon
iff means if and only if, but readers without that knowledge might assume this to be a spelling mistake. To me, this seems like exclusionary language that is unnecessary. Simply using "if and only if" instead should suffice. Notes: Merged: https://github.com/ruby/ruby/pull/4035
2020-12-12Signal handler type should be voidNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3889
2020-12-12trap on non-main ractorKoichi Sasada
trap can accept blopck/Proc and it can violate Rator isolation, so the Proc should be isolatable when trap is used on non-main ractor. Notes: Merged: https://github.com/ruby/ruby/pull/3888
2020-09-03Introduce Ractor mechanism for parallel executionKoichi Sasada
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. Notes: Merged: https://github.com/ruby/ruby/pull/3365
2020-07-22Share the size for sigaltstack between configure.ac and signal.cNobuyoshi Nakada
2020-07-11Fixed a comment, wrong binary prefix [ci skip]Nobuyoshi Nakada
2020-06-29add UNREACHABLE_RETURN卜部昌平
Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29trap_handler: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29signm2signo: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-03-06thread_pthread.c: allocate sigaltstack before pthread_createYusuke Endoh
A new (not-initialized-yet) pthread attempts to allocate sigaltstack by using xmalloc. It may cause GC, but because the thread is not initialized yet, ruby_native_thread_p() returns false, which leads to "[FATAL] failed to allocate memory" and exit. In fact, we can observe the error message in the log of OpenBSD CI: https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20200306T083005Z.log.html.gz This changeset allocates sigaltstack before pthread is created.
2019-12-26decouple 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). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-11-18Deprecate rb_eval_cmd, add rb_eval_cmd_kwJeremy Evans
rb_eval_cmd takes a safe level, and now that $SAFE is deprecated, it should be deprecated as well. Replace with rb_eval_cmd_kw, which takes a keyword flag. Switch the two callers to this function. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-10-09Share ruby_sighandler_t definitionNobuyoshi Nakada
2019-10-09signal.c: save the original sighandlers for fatal signalsYusuke Endoh
On Android, a signal handler that is not SIG_DFL is set by default for SIGSEGV. Ruby's install_sighandler inserts Ruby's handler only when the signal has no handler, so it does not insert Ruby's SEGV report handler, which caused some test failures. This changeset forces to install Ruby's handler for some fatal signals (sigbus, sigsegv, and sigill). They keep the original handlers, and call them when the interpreter receives the signals.
2019-10-09error.c (rb_bug_for_fatal_signal): renamed from rb_bug_contextYusuke Endoh
Just refactoring. The name "rb_bug_context" is completely unclear for me. (Can you see that "context" means "machine register context"?) The context is available only when a fatal signal (sigbus, sigsegv, or sigill) is received; in fact, the function is used only for fatal signals. So, I think the name should be changed.
2019-10-09signal.c (ruby_abort): move the definition for refactoringYusuke Endoh
The three functions for fatal signals, sigbus, sigsegv, and sigill, are a family. The definition of ruby_abort had interrupted them for no reason. This change just moves the definition after the family.
close