1. 22 Jul, 2015 1 commit
    • Ian Lance Taylor's avatar
      runtime: if we don't handle a signal on a non-Go thread, raise it · 872b168f
      Ian Lance Taylor authored
      In the past badsignal would crash the program.  In
      https://golang.org/cl/10757044 badsignal was changed to call sigsend,
      to fix issue #3250.  The effect of this was that when a non-Go thread
      received a signal, and os/signal.Notify was not being used to check
      for occurrences of the signal, the signal was ignored.
      
      This changes the code so that if os/signal.Notify is not being used,
      then the signal handler is reset to what it was, and the signal is
      raised again.  This lets non-Go threads handle the signal as they
      wish.  In particular, it means that a segmentation violation in a
      non-Go thread will ordinarily crash the process, as it should.
      
      Fixes #10139.
      Update #11794.
      
      Change-Id: I2109444aaada9d963ad03b1d071ec667760515e5
      Reviewed-on: https://go-review.googlesource.com/12503
      
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      872b168f
  2. 02 Jun, 2015 1 commit
  3. 23 May, 2015 1 commit
  4. 22 May, 2015 1 commit
    • Elias Naur's avatar
      runtime: don't always unblock all signals · 84cfba17
      Elias Naur authored
      Ian proposed an improved way of handling signals masks in Go, motivated
      by a problem where the Android java runtime expects certain signals to
      be blocked for all JVM threads. Discussion here
      
      https://groups.google.com/forum/#!topic/golang-dev/_TSCkQHJt6g
      
      Ian's text is used in the following:
      
      A Go program always needs to have the synchronous signals enabled.
      These are the signals for which _SigPanic is set in sigtable, namely
      SIGSEGV, SIGBUS, SIGFPE.
      
      A Go program that uses the os/signal package, and calls signal.Notify,
      needs to have at least one thread which is not blocking that signal,
      but it doesn't matter much which one.
      
      Unix programs do not change signal mask across execve.  They inherit
      signal masks across fork.  The shell uses this fact to some extent;
      for example, the job control signals (SIGTTIN, SIGTTOU, SIGTSTP) are
      blocked for commands run due to backquote quoting or $().
      
      Our current position on signal masks was not thought out.  We wandered
      into step by step, e.g., http://golang.org/cl/7323067 .
      
      This CL does the following:
      
      Introduce a new platform hook, msigsave, that saves the signal mask of
      the current thread to m.sigsave.
      
      Call msigsave from needm and newm.
      
      In minit grab set up the signal mask from m.sigsave and unblock the
      essential synchronous signals, and SIGILL, SIGTRAP, SIGPROF, SIGSTKFLT
      (for systems that have it).
      
      In unminit, restore the signal mask from m.sigsave.
      
      The first time that os/signal.Notify is called, start a new thread whose
      only purpose is to update its signal mask to make sure signals for
      signal.Notify are unblocked on at least one thread.
      
      The effect on Go programs will be that if they are invoked with some
      non-synchronous signals blocked, those signals will normally be
      ignored.  Previously, those signals would mostly be ignored.  A change
      in behaviour will occur for programs started with any of these signals
      blocked, if they receive the signal: SIGHUP, SIGINT, SIGQUIT, SIGABRT,
      SIGTERM.  Previously those signals would always cause a crash (unless
      using the os/signal package); with this change, they will be ignored
      if the program is started with the signal blocked (and does not use
      the os/signal package).
      
      ./all.bash completes successfully on linux/amd64.
      
      OpenBSD is missing the implementation.
      
      Change-Id: I188098ba7eb85eae4c14861269cc466f2aa40e8c
      Reviewed-on: https://go-review.googlesource.com/10173
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      84cfba17
  5. 14 Apr, 2015 1 commit
  6. 30 Mar, 2015 1 commit
    • Austin Clements's avatar
      runtime: make "write barriers are not allowed" comments more precise · 9e6f7aac
      Austin Clements authored
      Currently, various functions are marked with the comment
      
        // May run without a P, so write barriers are not allowed.
      
      However, "running without a P" is ambiguous. We intended these to mean
      that m.p may be nil (which is the condition checked by the write
      barrier). The comment could also be taken to mean that a
      stop-the-world may happen, which is not the case for these functions
      because they run in situations where there is in fact a function on
      the stack holding a P locally, it just isn't in m.p.
      
      Change these comments to state precisely what we mean, that m.p may be
      nil.
      
      Change-Id: I4a4a1d26aebd455e5067540e13b9f96a7482146c
      Reviewed-on: https://go-review.googlesource.com/8209
      
      Reviewed-by: default avatarMinux Ma <minux@golang.org>
      Reviewed-by: default avatarRick Hudson <rlh@golang.org>
      9e6f7aac
  7. 26 Mar, 2015 1 commit
    • Austin Clements's avatar
      runtime: disallow write barriers in handoffp and callees · 392336f9
      Austin Clements authored
      handoffp by definition runs without a P, so it's not allowed to have
      write barriers. It doesn't have any right now, but mark it
      nowritebarrier to disallow any creeping in in the future. handoffp in
      turns calls startm, newm, and newosproc, all of which are "below Go"
      and make sense to run without a P, so disallow write barriers in these
      as well.
      
      For most functions, we've done this because they may race with
      stoptheworld() and hence must not have write barriers. For these
      functions, it's a little different: the world can't stop while we're
      in handoffp, so this race isn't present. But we implement this
      restriction with a somewhat broader rule that you can't have a write
      barrier without a P. We like this rule because it's simple and means
      that our write barriers can depend on there being a P, even though
      this rule is actually a little broader than necessary. Hence, even
      though there's no danger of the race in these functions, we want to
      adhere to the broader rule.
      
      Change-Id: Ie22319c30eea37d703eb52f5c7ca5da872030b88
      Reviewed-on: https://go-review.googlesource.com/8130
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      Reviewed-by: default avatarMinux Ma <minux@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRick Hudson <rlh@golang.org>
      392336f9
  8. 13 Mar, 2015 1 commit
  9. 02 Mar, 2015 1 commit
  10. 25 Feb, 2015 1 commit
  11. 19 Feb, 2015 1 commit
  12. 28 Dec, 2014 1 commit
  13. 23 Dec, 2014 1 commit
    • Austin Clements's avatar
      runtime: run libc SIGSETXID and SIGCANCEL handlers on signal stack · 675eb72c
      Austin Clements authored
      These signals are used by glibc to broadcast setuid/setgid to all
      threads and to send pthread cancellations.  Unlike other signals, the
      Go runtime does not intercept these because they must invoke the libc
      handlers (see issues #3871 and #6997).  However, because 1) these
      signals may be issued asynchronously by a thread running C code to
      another thread running Go code and 2) glibc does not set SA_ONSTACK
      for its handlers, glibc's signal handler may be run on a Go stack.
      Signal frames range from 1.5K on amd64 to many kilobytes on ppc64, so
      this may overflow the Go stack and corrupt heap (or other stack) data.
      
      Fix this by ensuring that these signal handlers have the SA_ONSTACK
      flag (but not otherwise taking over the handler).
      
      This has been a problem since Go 1.1, but it's likely that people
      haven't encountered it because it only affects setuid/setgid and
      pthread_cancel.
      
      Fixes #9600.
      
      Change-Id: I6cf5f5c2d3aa48998d632f61f1ddc2778dcfd300
      Reviewed-on: https://go-review.googlesource.com/1887
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      675eb72c
  14. 10 Dec, 2014 1 commit
  15. 14 Nov, 2014 3 commits