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

234 Коммитов

Автор SHA1 Сообщение Дата
nobu a59ba5073e signal.c: use mcontext_t
* signal.c (check_stack_overflow): use mcontext_t.  the struct tag
  name is not portable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 08:15:16 +00:00
nobu f4f71d6e6b signal.c: check stack overflow by SP
* signal.c (check_stack_overflow): raise SystemStackError if SP
  register and fault address is in the same page or the next, on
  x86 Mac OS X.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 07:38:54 +00:00
nobu 4f8c0b90bb signal.c: check the next page too
* signal.c (check_stack_overflow): check the next page too.  SP in
  ucontext is not decremented yet when `push` failed, so the fault
  page can be the next.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-12 01:35:09 +00:00
nobu a3656d4222 signal.c: directly deliver non-handlable signals
* signal.c (rb_f_kill): directly deliver signals which cannot be
  handled, i.e., SIGKILL and SIGSTOP.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-11 01:02:47 +00:00
nobu 77af38d0a5 signal.c: directly enqueue
* signal.c (rb_f_kill): directly enqueue an ignored signal to self,
  except for SIGSEGV and SIGBUS.  [ruby-dev:48203] [Bug #9820]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10 16:10:32 +00:00
akr 08928bb528 * signal.c (trap): Return "SYSTEM_DEFAULT" if SIG_DFL is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-09 23:48:47 +00:00
nobu b60fbca806 signal.c: if to switch
* signal.c (ruby_signal): turn multiple `if` statements into a
  `switch`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-09 14:31:27 +00:00
akr f0cbb868e7 * signal.c (check_stack_overflow): Don't use ucontext_t if ucontext.h
is not available.
  Fixes build on Android (x86).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-09 23:16:10 +00:00
nobu c3699626da signal.c: check stack overflow by SP
* signal.c (check_stack_overflow): raise SystemStackError if SP
  register and fault address is in the same page, on x86 linux.
  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-04 08:37:25 +00:00
nobu d14458fb41 signal.c: preserve encoding
* signal.c (esignal_init): preserve encoding in error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-31 02:34:43 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
nobu a97bb1a2f7 signal.c: static literal string
* signal.c (sigsegv): make message string static to suppress
  unnecessary copy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-27 13:09:26 +00:00
nobu 24bcd4ce67 signal.c: fault address
* signal.c (sigbus, sigsegv): show fault address in the bug message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 03:18:49 +00:00
usa 1df5ebf450 * eval_intern.h (SAVE_ROOT_JMPBUF): workaround for the failure of
test/ruby/test_exception.rb on Windows.
  wrap by __try and __exception statements on mswin to raise SIGSEGV
  when EXCEPTION_STACK_OVERFLOW is occurred, because MSVCRT doesn't
  handle the exception.
  however, (1) mingw-gcc doesn't support __try and __exception
  statements, and (2) we cannot retry SystemStackError after this
  change yet (maybe crashed) because SEH and longjmp() are too
  uncongenial.

* signal.c (check_stack_overflow, CHECK_STACK_OVERFLOW): now defined on
  Windows, too.

* thread_win32.c (ruby_stack_overflowed_p): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 06:33:41 +00:00
nobu 78d0fdcec9 signal.c: adjust indent
* signal.c (ruby_atomic_compare_and_swap): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 10:07:11 +00:00
nobu 7f41aa5f09 signal.c: get rid of system name
* signal.c (sighandler_t): get rid of clash with system provided name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06 13:52:39 +00:00
nobu e4ef4ddd56 signal.c: adjust style
* signal.c (rb_sigaltstack_size, ruby_abort): adjust style,
  procnames-start-lines.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-12 05:37:04 +00:00
nobu 3048637571 signal.c: suppress a warning
* signal.c (ruby_signal): suppress unused-value warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14 17:43:55 +00:00
nobu 342259a328 signal.c: for valgrind
* signal.c (ruby_signal): suppress valgrind error in
  install_sighandler().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-12 07:37:31 +00:00
usa ccf07bde23 * signal.c: need to include unistd.h for write(2).
unistd.h is now included via ruby/defines.h, but should implicitly
  include here.  (suggested by kosaki)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-14 15:44:14 +00:00
kosaki c0a30fcbf9 * signal.c (rb_f_kill): fixes typo. s/HAS_KILLPG/HAVE_KILLPG/.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-12 08:41:46 +00:00
hsbt 66aa6aa500 Fixed comment typo by @qqshfox [fix GH-279]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 00:24:24 +00:00
nobu 985deb62eb envutil.rb: signal in Process::Status
* test/ruby/envutil.rb (assert_ruby_status): show status info.

* test/ruby/envutil.rb (Test::Unit::Assertions::FailDesc): use
  Signal.signame for consistency with Process::Status#inspect.

* signal.c (siglist): prefer SIGABRT over SIGIOT in Signal.signame.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-25 05:39:29 +00:00
kosaki 4ea96ece84 * internal.h: added a declaration of ruby_kill().
* thread.c (ruby_kill): helper function of kill().

* signal.c (rb_f_kill): use ruby_kill() instead of kill().
* signal.c (rb_f_kill): call rb_thread_execute_interrupts()
  to ensure that make SignalException if sent a signal
  to myself. [Bug #7951] [ruby-core:52864]

* vm_core.h (typedef struct rb_thread_struct): added
  th->interrupt_cond.
* thread.c (rb_threadptr_interrupt_common): added to
  initialization of th->interrupt_cond.
* thread.c (thread_create_core): ditto.

* test/ruby/test_signal.rb (TestSignal#test_hup_me): test for
  the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19 04:40:22 +00:00
nobu 6217417799 signal.c: fix type
* signal.c (sigsegv): type of write(2) is ssize_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24 01:16:46 +00:00
kosaki bc5a5989c0 * signal.c (sigsegv): suppress unused result warning. Because
write(2) is marked __warn_unused_result__ on Linux glibc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24 00:17:29 +00:00
ngoto c84a9acb28 * signal.c (ruby_abort): fix typo in r39354 [Bug #5014]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22 06:02:54 +00:00
nobu 087e888a15 signal.c: extract check_stack_overflow
* signal.c (check_stack_overflow): extract duplicated code and get rid
  of declaration-after-statement.  [Bug #5014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-21 07:34:53 +00:00
kosaki 7355c6d9c9 * signal.c (sigsegv): avoid to use async signal unsafe functions
when nested sigsegv is happen.
  [Bug #5014] [ruby-dev:44082]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-21 05:18:38 +00:00
ko1 0f9b33c793 * thread.c: rename methods:
from Thread.async_interrupt_timing to Thread.handle_interrupt,
  from Thread.async_interrupted? to Thread.pending_interrupt?.
  Also rename option from `defer' to `never'.
  [ruby-core:51074] [ruby-trunk - Feature #6762]
* vm_core.c, thread.c: rename functions and data structure
  `async_errinfo' to `pending_interrupt'.
* thread.c: add global variables sym_immediate, sym_on_blocking and
  sym_never.
* cont.c, process.c, vm.c, signal.c: ditto.
* lib/sync.rb, lib/thread.rb: catch up this renaming.
* test/ruby/test_thread.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-23 10:18:58 +00:00
kosaki 44b4b9060d * signal.c (rb_sigaltstack_size): cast sysconf() return value
explicitly. Fix compile error on Mac OS X.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 17:10:50 +00:00
kosaki 0e19d2b434 * signal.c (default_handler): remove rb_register_sigaltstack()
call. sigaltstack was already registered when creating threads.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 14:20:24 +00:00
kosaki aff9dff46d * signal.c (rb_sigaltstack_size): new. calculate stack size for
sigsegv handler. enlarge value when x86 or x86_64 on Linux.
  Linux has very small MINSIGSTKSZ size (2048 bytes) and
  our sigsegv routine need 5KiB at least. [Bug #7141]
* internal.h: add declaration of rb_sigaltstack_size().
* vm_core.h: remove ALT_STACK_SIZE definition.

* signal.c (rb_register_sigaltstack): replace ALT_STACK_SIZE with
  rb_sigaltstack_size();
* gc.c (Init_heap): ditto.
* vm.c (th_init): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 14:20:12 +00:00
kosaki cb92817e7c * signal.c (rb_f_kill): remove rb_thread_polling() because this
has no good effect and makes meaningless 100ms delay. 1)
  when sending signal to another process, waiting has just silly.
  2) when sending signal to current process, 100ms is often not
  enough time to wait. It depend on kernel behavior. And,
  rb_thread_polling() doesn't make sense anyway. When rb_thread_alone()
  is true, it doesn't wait at all and Process.kill() users don't
  expect threading changes Process.kill() behavior. [Bug #7560]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-14 15:11:59 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
ngoto 5faf4cc77b * ruby_atomic.h (ATOMIC_CAS): added for Solaris and other platforms.
* ruby_atomic.h, signal.c (NEED_RUBY_ATOMIC_OPS): renamed from
  NEED_RUBY_ATOMIC_EXCHANGE.
* signal.c (ruby_atomic_compare_and_swap): naive, non-atomic
  compare-and-swap implementation only used for platforms without
  valid support for atomic operations.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 10:21:59 +00:00
kosaki 66e2e6ee69 * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT)
(RUBY_VM_SET_FINALIZER_INTERRUPT, RUBY_VM_SET_TRAP_INTERRUPT)
(RUBY_VM_INTERRUPTED): use enum symbol instead of immediate value.
* thread.c (thread_join_m, rb_threadptr_execute_interrupts): ditto.
* signal.c (signal_exec): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 12:17:10 +00:00
kosaki 58543f00b6 * thread.c (thread_join_m): use th->interrupt_mask instead of
th->in_trap.

* vm_core.h (struct rb_thread_struct): remove in_trap member.
* signal.c (signal_exec): ditto.
* thread.c (thread_create_core): ditto.
* thread.c (Init_Thread): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 11:45:39 +00:00
kosaki 6190bb4d8a * ruby_atomic.h (ATOMIC_CAS): new macro for compare-and-exchange.
* vm_core.h (struct rb_thread_struct): add interrupt_mask member.
* thread.c (thread_create_core, Init_Thread): initialize
  th->thread_mask.

* vm_core.h (RUBY_VM_INTERRUPTED_ANY): new macro for avoiding
  bare th->interrupt_flag.
* vm_core.h (RUBY_VM_INTERRUPTED, RUBY_VM_INTERRUPTED): check
  th->interrupt_mask.
* thread.c (set_unblock_function, rb_thread_schedule): replace
  th->interrupt_flag with RUBY_VM_INTERRUPTED_ANY()

* signal.c (signal_exec): set up thread->interrupt_mask for
  preventing recursive trap handler.
* vm_core.h (RUBY_VM_CHECK_INTS, RUBY_VM_CHECK_INTS_BLOCKING): ditto.

* thread.c (rb_threadptr_execute_interrupts):
  don't process interrupt if it is masked.
  [Bug #6009] [ruby-core:42524]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 10:57:39 +00:00
kosaki 521af83558 * signal.c (signal_exec): add volatile to make sure setjmp safe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 09:28:35 +00:00
kosaki 458796d4f1 * signal.c (signal_exec): suppress "warning: variable 'signum'
might be clobbered by 'longjmp' or 'vfork'" warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 09:25:47 +00:00
kosaki f150ed1532 * vm_core.h (rb_thread_struct): added 'in_trap' member for marking
running trap handler.
* signal.c (signal_exec): turn on in_trap when running trap.
* thread.c (Init_Thread, thread_create_core): initialize in_trap
  when creating new threads.
* thread.c (thread_join_m): raise ThreadError when running trap
  handler.Bug [#6416][ruby-core:44956]
* test/ruby/test_thread.rb (test_thread_join_in_trap): new test
  for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 08:05:49 +00:00
kosaki 6d9f7672dd * signal.c (rb_get_next_signal): removed pointless signal
disabling. pthread_sigmask() only changes current thread
  mask.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 10:54:55 +00:00
kosaki 562cb0ae59 * signal.c (install_sighandler): added comments why we need
rb_disable_interrupt().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 10:38:02 +00:00
kosaki 75df3aae0f * signal.c (rb_disable_interrupt, rb_enable_interrupt): removed
USE_TRAP_MASK.
* signal.c (trap_arg, trap_ensure): removed.
* signal.c (trap, sig_trap): removed pointless signal disabling.
  We don't need it bacause we no longer run trap hander on signal
  hander context.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 10:35:34 +00:00
kosaki 58282ed667 * signal.c (sig_signame): implements Signal.signame method
[Feature #5613]
* test/ruby/test_signal.rb (test_signame): adds test for above
* NEWS: add an item about above



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 09:43:53 +00:00
ngoto 05a05cc62b * ruby_atomic.h: renamed from atomic.h to avoid header file name conflict
on Solaris 10. [ruby-dev:46414] [Bug #7287]
* gc.c, signal.c, vm_core.h, common.mk: reflect the rename from atomic.h
  to ruby_atomic.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 16:05:07 +00:00
zzak b1228caeff * signal.c (rb_f_kill):
Update documentation for Process.kill to reflect kill(2)
  Patch by Richo Healey


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-13 15:24:05 +00:00
naruse f896ad3b49 * configure.in: Fixing Haiku build.
- -lbe is not required for linking
  - stack protector doesn't work for now because of the default gcc's bug
  by Takashi Toyoshima <toyoshim@gmail.com>
  https://github.com/ruby/ruby/pull/167

* signal.c (ruby_signal): haiku doesn't have SIGBUS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 02:59:24 +00:00
kosaki 3e1d8aab17 * dln.c: Simplify and make consistent an ifdef for Mac OS X.
* ext/socket/rubysocket.h: ditto.
* ext/tk/stubs.c: ditto.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* vm_dump.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-09 15:52:49 +00:00