summaryrefslogtreecommitdiff
path: root/src/runtime/panic.go
Commit message (Collapse)AuthorAgeFilesLines
* all: power64 is now ppc64Russ Cox2014-12-051-1/+1
| | | | | | | | | Fixes issue 8654. LGTM=austin R=austin CC=golang-codereviews https://codereview.appspot.com/180600043
* [dev.cc] runtime: two missed references to "M stack"Austin Clements2014-11-181-1/+1
| | | | | | | LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/177940043
* [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.ccRuss Cox2014-11-141-23/+27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes. These are the files that had merge conflicts and have been edited by hand: malloc.go mem_linux.go mgc.go os1_linux.go proc1.go panic1.go runtime1.go LGTM=austin R=austin CC=golang-codereviews https://codereview.appspot.com/174180043
| * [dev.cc] runtime: delete scalararg, ptrarg; rename onM to systemstackRuss Cox2014-11-121-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Scalararg and ptrarg are not "signal safe". Go code filling them out can be interrupted by a signal, and then the signal handler runs, and if it also ends up in Go code that uses scalararg or ptrarg, now the old values have been smashed. For the pieces of code that do need to run in a signal handler, we introduced onM_signalok, which is really just onM except that the _signalok is meant to convey that the caller asserts that scalarg and ptrarg will be restored to their old values after the call (instead of the usual behavior, zeroing them). Scalararg and ptrarg are also untyped and therefore error-prone. Go code can always pass a closure instead of using scalararg and ptrarg; they were only really necessary for C code. And there's no more C code. For all these reasons, delete scalararg and ptrarg, converting the few remaining references to use closures. Once those are gone, there is no need for a distinction between onM and onM_signalok, so replace both with a single function equivalent to the current onM_signalok (that is, it can be called on any of the curg, g0, and gsignal stacks). The name onM and the phrase 'm stack' are misnomers, because on most system an M has two system stacks: the main thread stack and the signal handling stack. Correct the misnomer by naming the replacement function systemstack. Fix a few references to "M stack" in code. The main motivation for this change is to eliminate scalararg/ptrarg. Rick and I have already seen them cause problems because the calling sequence m.ptrarg[0] = p is a heap pointer assignment, so it gets a write barrier. The write barrier also uses onM, so it has all the same problems as if it were being invoked by a signal handler. We worked around this by saving and restoring the old values and by calling onM_signalok, but there's no point in keeping this nice home for bugs around any longer. This CL also changes funcline to return the file name as a result instead of filling in a passed-in *string. (The *string signature is left over from when the code was written in and called from C.) That's arguably an unrelated change, except that once I had done the ptrarg/scalararg/onM cleanup I started getting false positives about the *string argument escaping (not allowed in package runtime). The compiler is wrong, but the easiest fix is to write the code like Go code instead of like C code. I am a bit worried that the compiler is wrong because of some use of uninitialized memory in the escape analysis. If that's the reason, it will go away when we convert the compiler to Go. (And if not, we'll debug it the next time.) LGTM=khr R=r, khr CC=austin, golang-codereviews, iant, rlh https://codereview.appspot.com/174950043
| * [dev.cc] runtime: convert panic and stack code from C to GoRuss Cox2014-11-111-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | The conversion was done with an automated tool and then modified only as necessary to make it compile and run. [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] LGTM=r R=r, dave CC=austin, dvyukov, golang-codereviews, iant, khr https://codereview.appspot.com/166520043
* | [dev.power64] all: merge default into dev.power64Austin Clements2014-10-221-2/+2
|\ \ | |/ |/| | | | | | | | | | | | | | | | | This brings dev.power64 up-to-date with the current tip of default. go_bootstrap is still panicking with a bad defer when initializing the runtime (even on amd64). LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/152570049
| * build: merge the great pkg/ rename into dev.power64Austin Clements2014-10-221-1/+1
| | | | | | | | | | | | | | | | | | This also removes pkg/runtime/traceback_lr.c, which was ported to Go in an earlier commit and then moved to runtime/traceback.go. Reviewer: rsc@golang.org rsc: LGTM
* | runtime: clear Defer.fn before removing from the G.defer listRuss Cox2014-10-081-0/+13
| | | | | | | | | | | | | | | | Should fix the remaining 'invalid heap pointer' build failures. TBR=khr CC=golang-codereviews https://codereview.appspot.com/152360043
* | runtime: fix windows/amd64 buildRuss Cox2014-10-071-2/+8
| | | | | | | | | | | | | | | | | | Out of stack space due to new 2-word call in freedefer. Go back to smaller function calls. TBR=brainman CC=golang-codereviews https://codereview.appspot.com/152340043
* | runtime: clear Defer.panic before removing from G.defer listRuss Cox2014-10-071-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Another dangling stack pointer in a cached structure. Same as SudoG.elem and SudoG.selectdone. Definitely a fix, and the new test in freedefer makes the crash reproducible, but probably not a complete fix. I have seen one dangling pointer in a Defer.panic even after this fix; I cannot see where it could be coming from. I think this will fix the solaris build. I do not think this will fix the occasional failure on the darwin build. TBR=khr R=khr CC=golang-codereviews https://codereview.appspot.com/155080043
* | runtime: Fix interaction between Goexit and defersKeith Randall2014-09-191-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | When running defers, we must check whether the defer has already been marked as started so we don't run it twice. Fixes issue 8774. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/142280044
* | runtime: delete panicstring; move its checks into gopanicRuss Cox2014-09-181-30/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Go 1.3 the runtime called panicstring to report errors like divide by zero or memory faults. Now we call panic (gopanic) with pre-allocated error values. That new path is missing the checking that panicstring did, so add it there. The only call to panicstring left is in cnew, which is problematic because if it fails, probably the heap is corrupt. In that case, calling panicstring creates a new errorCString (no allocation there), but then panic tries to print it, invoking errorCString.Error, which does a string concatenation (allocating), which then dies. Replace that one panicstring with a throw: cnew is for allocating runtime data structures and should never ask for an inappropriate amount of memory. With panicstring gone, delete newErrorCString, errorCString. While we're here, delete newErrorString, not called by anyone. (It can't be: that would be C code calling Go code that might block or grow the stack.) Found while debugging a malloc corruption. This resulted in 'panic during panic' instead of a more useful message. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/138290045
* | runtime: make it clear that Goexit cannot be recover'd.Keith Randall2014-09-161-1/+2
| | | | | | | | | | | | | | LGTM=r R=r, bradfitz, khr CC=golang-codereviews https://codereview.appspot.com/136660044
* | runtime: use traceback to traverse defer structuresRuss Cox2014-09-161-43/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the GC and the stack copying agree about how to interpret the defer structures. Previously, only the stack copying treated them precisely. This removes an untyped memory allocation and fixes at least three copystack bugs. To make sure the GC can find the deferred argument frame until it has been copied, keep a Defer on the defer list during its execution. In addition to making it possible to remove the untyped memory allocation, keeping the Defer on the list fixes two races between copystack and execution of defers (in both gopanic and Goexit). The problem is that once the defer has been taken off the list, a stack copy that happens before the deferred arguments have been copied back to the stack will not update the arguments correctly. The new tests TestDeferPtrsPanic and TestDeferPtrsGoexit (variations on the existing TestDeferPtrs) pass now but failed before this CL. In addition to those fixes, keeping the Defer on the list helps correct a dangling pointer error during copystack. The traceback routines walk the Defer chain to provide information about where a panic may resume execution. When the executing Defer was not on the Defer chain but instead linked from the Panic chain, the traceback had to walk the Panic chain too. But Panic structs are on the stack and being updated by copystack. Traceback's use of the Panic chain while copystack is updating those structs means that it can follow an updated pointer and find itself reading from the new stack. The new stack is usually all zeros, so it sees an incorrect early end to the chain. The new TestPanicUseStack makes this happen at tip and dies when adjustdefers finds an unexpected argp. The new StackCopyPoison mode causes an earlier bad dereference instead. By keeping the Defer on the list, traceback can avoid walking the Panic chain at all, making it okay for copystack to update the Panics. We'd have the same problem for any Defers on the stack. There was only one: gopanic's dabort. Since we are not taking the executing Defer off the chain, we can use it to do what dabort was doing, and then there are no Defers on the stack ever, so it is okay for traceback to use the Defer chain even while copystack is executing: copystack cannot modify the Defer chain. LGTM=khr R=khr CC=dvyukov, golang-codereviews, iant, rlh https://codereview.appspot.com/141490043
* | runtime: allow crash from gsignal stackRuss Cox2014-09-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | The uses of onM in dopanic/startpanic are okay even from the signal stack. Fixes issue 8666. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/134710043
* | runtime: merge mallocgc, gomallocgcRuss Cox2014-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I assumed they were the same when I wrote cgocallback.go earlier today. Merge them to eliminate confusion. I can't tell what gomallocgc did before with a nil type but without FlagNoScan. I created a call like that in cgocallback.go this morning, translating from a C file. It was supposed to do what the C version did, namely treat the block conservatively. Now it will. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/141810043
* | runtime: let stack copier update Panic structs for usRuss Cox2014-09-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | It already is updating parts of them; we're just getting lucky retraversing them and not finding much to do. Change argp to a pointer so that it will be updated too. Existing tests break if you apply the change to adjustpanics without also updating the type of argp. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/139380043
* | runtime: mark freedefer and deferclass go:nosplitRuss Cox2014-09-081-0/+2
| | | | | | | | | | | | | | | | | | | | This should make deferreturn nosplit all the way down, which should fix the current windows/amd64 failure. If not, I will change StackCopyAlways back to 0. TBR=khr CC=golang-codereviews https://codereview.appspot.com/135600043
* | runtime: merge panic1.go back into panic.goKeith Randall2014-09-081-0/+202
| | | | | | | | | | | | | | LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/139370043
* | liblink, runtime: diagnose and fix C code running on Go stackRuss Cox2014-09-081-0/+20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL contains compiler+runtime changes that detect C code running on Go (not g0, not gsignal) stacks, and it contains corrections for what it detected. The detection works by changing the C prologue to use a different stack guard word in the G than Go prologue does. On the g0 and gsignal stacks, that stack guard word is set to the usual stack guard value. But on ordinary Go stacks, that stack guard word is set to ^0, which will make any stack split check fail. The C prologue then calls morestackc instead of morestack, and morestackc aborts the program with a message about running C code on a Go stack. This check catches all C code running on the Go stack except NOSPLIT code. The NOSPLIT code is allowed, so the check is complete. Since it is a dynamic check, the code must execute to be caught. But unlike the static checks we've been using in cmd/ld, the dynamic check works with function pointers and other indirect calls. For example it caught sigpanic being pushed onto Go stacks in the signal handlers. Fixes issue 8667. LGTM=khr, iant R=golang-codereviews, khr, iant CC=golang-codereviews, r https://codereview.appspot.com/133700043
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+216
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.