From 32b94f13cf35e619a0dae6e1e381adc7e182d283 Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Wed, 2 Aug 2017 19:01:17 +0100 Subject: runtime: move selectdone into g Writing to selectdone on the stack of another goroutine meant a pretty subtle dance between the select code and the stack copying code. Instead move the selectdone variable into the g struct. Change-Id: Id246aaf18077c625adef7ca2d62794afef1bdd1b Reviewed-on: https://go-review.googlesource.com/53390 Reviewed-by: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- src/runtime/stack.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 525d0b14c1..d353329a39 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -751,7 +751,6 @@ func adjustsudogs(gp *g, adjinfo *adjustinfo) { // might be in the stack. for s := gp.waiting; s != nil; s = s.waitlink { adjustpointer(adjinfo, unsafe.Pointer(&s.elem)) - adjustpointer(adjinfo, unsafe.Pointer(&s.selectdone)) } } @@ -768,10 +767,6 @@ func findsghi(gp *g, stk stack) uintptr { if stk.lo <= p && p < stk.hi && p > sghi { sghi = p } - p = uintptr(unsafe.Pointer(sg.selectdone)) + unsafe.Sizeof(sg.selectdone) - if stk.lo <= p && p < stk.hi && p > sghi { - sghi = p - } } return sghi } -- cgit v1.3 From 59413d34c92cf5ce9b0e70e7105ed73a24849b3e Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Thu, 17 Aug 2017 15:51:35 +0100 Subject: all: unindent some big chunks of code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found with mvdan.cc/unindent. Prioritized the ones with the biggest wins for now. Change-Id: I2b032e45cdd559fc9ed5b1ee4c4de42c4c92e07b Reviewed-on: https://go-review.googlesource.com/56470 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/bytes/bytes.go | 55 +++++++++++++------------- src/debug/dwarf/type.go | 75 ++++++++++++++++++------------------ src/go/build/build.go | 35 ++++++++--------- src/go/types/call.go | 67 ++++++++++++++++---------------- src/math/expm1.go | 50 ++++++++++++------------ src/runtime/mheap.go | 51 +++++++++++++------------ src/runtime/os_linux.go | 71 +++++++++++++++++----------------- src/runtime/panic.go | 57 +++++++++++++-------------- src/runtime/stack.go | 43 +++++++++++---------- src/text/tabwriter/tabwriter.go | 85 +++++++++++++++++++++-------------------- 10 files changed, 298 insertions(+), 291 deletions(-) (limited to 'src/runtime/stack.go') diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 457e149410..446026233e 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -285,38 +285,39 @@ func Fields(s []byte) [][]byte { wasSpace = isSpace } - if setBits < utf8.RuneSelf { // ASCII fast path - a := make([][]byte, n) - na := 0 - fieldStart := 0 - i := 0 - // Skip spaces in the front of the input. - for i < len(s) && asciiSpace[s[i]] != 0 { + if setBits >= utf8.RuneSelf { + // Some runes in the input slice are not ASCII. + return FieldsFunc(s, unicode.IsSpace) + } + + // ASCII fast path + a := make([][]byte, n) + na := 0 + fieldStart := 0 + i := 0 + // Skip spaces in the front of the input. + for i < len(s) && asciiSpace[s[i]] != 0 { + i++ + } + fieldStart = i + for i < len(s) { + if asciiSpace[s[i]] == 0 { i++ + continue } - fieldStart = i - for i < len(s) { - if asciiSpace[s[i]] == 0 { - i++ - continue - } - a[na] = s[fieldStart:i] - na++ + a[na] = s[fieldStart:i] + na++ + i++ + // Skip spaces in between fields. + for i < len(s) && asciiSpace[s[i]] != 0 { i++ - // Skip spaces in between fields. - for i < len(s) && asciiSpace[s[i]] != 0 { - i++ - } - fieldStart = i } - if fieldStart < len(s) { // Last field might end at EOF. - a[na] = s[fieldStart:] - } - return a + fieldStart = i } - - // Some runes in the input slice are not ASCII. - return FieldsFunc(s, unicode.IsSpace) + if fieldStart < len(s) { // Last field might end at EOF. + a[na] = s[fieldStart:] + } + return a } // FieldsFunc interprets s as a sequence of UTF-8-encoded Unicode code points. diff --git a/src/debug/dwarf/type.go b/src/debug/dwarf/type.go index 9b39078a6f..72ef816cc2 100644 --- a/src/debug/dwarf/type.go +++ b/src/debug/dwarf/type.go @@ -514,48 +514,49 @@ func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Off var lastFieldType *Type var lastFieldBitOffset int64 for kid := next(); kid != nil; kid = next() { - if kid.Tag == TagMember { - f := new(StructField) - if f.Type = typeOf(kid); err != nil { + if kid.Tag != TagMember { + continue + } + f := new(StructField) + if f.Type = typeOf(kid); err != nil { + goto Error + } + switch loc := kid.Val(AttrDataMemberLoc).(type) { + case []byte: + // TODO: Should have original compilation + // unit here, not unknownFormat. + b := makeBuf(d, unknownFormat{}, "location", 0, loc) + if b.uint8() != opPlusUconst { + err = DecodeError{name, kid.Offset, "unexpected opcode"} goto Error } - switch loc := kid.Val(AttrDataMemberLoc).(type) { - case []byte: - // TODO: Should have original compilation - // unit here, not unknownFormat. - b := makeBuf(d, unknownFormat{}, "location", 0, loc) - if b.uint8() != opPlusUconst { - err = DecodeError{name, kid.Offset, "unexpected opcode"} - goto Error - } - f.ByteOffset = int64(b.uint()) - if b.err != nil { - err = b.err - goto Error - } - case int64: - f.ByteOffset = loc + f.ByteOffset = int64(b.uint()) + if b.err != nil { + err = b.err + goto Error } + case int64: + f.ByteOffset = loc + } - haveBitOffset := false - f.Name, _ = kid.Val(AttrName).(string) - f.ByteSize, _ = kid.Val(AttrByteSize).(int64) - f.BitOffset, haveBitOffset = kid.Val(AttrBitOffset).(int64) - f.BitSize, _ = kid.Val(AttrBitSize).(int64) - t.Field = append(t.Field, f) - - bito := f.BitOffset - if !haveBitOffset { - bito = f.ByteOffset * 8 - } - if bito == lastFieldBitOffset && t.Kind != "union" { - // Last field was zero width. Fix array length. - // (DWARF writes out 0-length arrays as if they were 1-length arrays.) - zeroArray(lastFieldType) - } - lastFieldType = &f.Type - lastFieldBitOffset = bito + haveBitOffset := false + f.Name, _ = kid.Val(AttrName).(string) + f.ByteSize, _ = kid.Val(AttrByteSize).(int64) + f.BitOffset, haveBitOffset = kid.Val(AttrBitOffset).(int64) + f.BitSize, _ = kid.Val(AttrBitSize).(int64) + t.Field = append(t.Field, f) + + bito := f.BitOffset + if !haveBitOffset { + bito = f.ByteOffset * 8 + } + if bito == lastFieldBitOffset && t.Kind != "union" { + // Last field was zero width. Fix array length. + // (DWARF writes out 0-length arrays as if they were 1-length arrays.) + zeroArray(lastFieldType) } + lastFieldType = &f.Type + lastFieldBitOffset = bito } if t.Kind != "union" { b, ok := e.Val(AttrByteSize).(int64) diff --git a/src/go/build/build.go b/src/go/build/build.go index fd89871d42..e9fd03cd8c 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -1195,25 +1195,26 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary p = p[len(p):] } line = bytes.TrimSpace(line) - if bytes.HasPrefix(line, slashslash) { - if bytes.Equal(line, binaryOnlyComment) { - sawBinaryOnly = true - } - line = bytes.TrimSpace(line[len(slashslash):]) - if len(line) > 0 && line[0] == '+' { - // Looks like a comment +line. - f := strings.Fields(string(line)) - if f[0] == "+build" { - ok := false - for _, tok := range f[1:] { - if ctxt.match(tok, allTags) { - ok = true - } - } - if !ok { - allok = false + if !bytes.HasPrefix(line, slashslash) { + continue + } + if bytes.Equal(line, binaryOnlyComment) { + sawBinaryOnly = true + } + line = bytes.TrimSpace(line[len(slashslash):]) + if len(line) > 0 && line[0] == '+' { + // Looks like a comment +line. + f := strings.Fields(string(line)) + if f[0] == "+build" { + ok := false + for _, tok := range f[1:] { + if ctxt.match(tok, allTags) { + ok = true } } + if !ok { + allok = false + } } } } diff --git a/src/go/types/call.go b/src/go/types/call.go index ffd9629777..345df66a8a 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -134,47 +134,46 @@ type getter func(x *operand, i int) // the incoming getter with that i. // func unpack(get getter, n int, allowCommaOk bool) (getter, int, bool) { - if n == 1 { - // possibly result of an n-valued function call or comma,ok value - var x0 operand - get(&x0, 0) - if x0.mode == invalid { - return nil, 0, false - } + if n != 1 { + // zero or multiple values + return get, n, false + } + // possibly result of an n-valued function call or comma,ok value + var x0 operand + get(&x0, 0) + if x0.mode == invalid { + return nil, 0, false + } + + if t, ok := x0.typ.(*Tuple); ok { + // result of an n-valued function call + return func(x *operand, i int) { + x.mode = value + x.expr = x0.expr + x.typ = t.At(i).typ + }, t.Len(), false + } - if t, ok := x0.typ.(*Tuple); ok { - // result of an n-valued function call + if x0.mode == mapindex || x0.mode == commaok { + // comma-ok value + if allowCommaOk { + a := [2]Type{x0.typ, Typ[UntypedBool]} return func(x *operand, i int) { x.mode = value x.expr = x0.expr - x.typ = t.At(i).typ - }, t.Len(), false - } - - if x0.mode == mapindex || x0.mode == commaok { - // comma-ok value - if allowCommaOk { - a := [2]Type{x0.typ, Typ[UntypedBool]} - return func(x *operand, i int) { - x.mode = value - x.expr = x0.expr - x.typ = a[i] - }, 2, true - } - x0.mode = value + x.typ = a[i] + }, 2, true } - - // single value - return func(x *operand, i int) { - if i != 0 { - unreachable() - } - *x = x0 - }, 1, false + x0.mode = value } - // zero or multiple values - return get, n, false + // single value + return func(x *operand, i int) { + if i != 0 { + unreachable() + } + *x = x0 + }, 1, false } // arguments checks argument passing for the call with the given signature. diff --git a/src/math/expm1.go b/src/math/expm1.go index 7dd75a88f4..8e77398adc 100644 --- a/src/math/expm1.go +++ b/src/math/expm1.go @@ -205,33 +205,33 @@ func expm1(x float64) float64 { r1 := 1 + hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))) t := 3 - r1*hfx e := hxs * ((r1 - t) / (6.0 - x*t)) - if k != 0 { - e = (x*(e-c) - c) - e -= hxs - switch { - case k == -1: - return 0.5*(x-e) - 0.5 - case k == 1: - if x < -0.25 { - return -2 * (e - (x + 0.5)) - } - return 1 + 2*(x-e) - case k <= -2 || k > 56: // suffice to return exp(x)-1 - y := 1 - (e - x) - y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent - return y - 1 - } - if k < 20 { - t := Float64frombits(0x3ff0000000000000 - (0x20000000000000 >> uint(k))) // t=1-2**-k - y := t - (e - x) - y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent - return y + if k == 0 { + return x - (x*e - hxs) // c is 0 + } + e = (x*(e-c) - c) + e -= hxs + switch { + case k == -1: + return 0.5*(x-e) - 0.5 + case k == 1: + if x < -0.25 { + return -2 * (e - (x + 0.5)) } - t := Float64frombits(uint64(0x3ff-k) << 52) // 2**-k - y := x - (e + t) - y++ + return 1 + 2*(x-e) + case k <= -2 || k > 56: // suffice to return exp(x)-1 + y := 1 - (e - x) + y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent + return y - 1 + } + if k < 20 { + t := Float64frombits(0x3ff0000000000000 - (0x20000000000000 >> uint(k))) // t=1-2**-k + y := t - (e - x) y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent return y } - return x - (x*e - hxs) // c is 0 + t = Float64frombits(uint64(0x3ff-k) << 52) // 2**-k + y := x - (e + t) + y++ + y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent + return y } diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index bf41125764..68f32aa01b 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -1129,34 +1129,35 @@ func scavengelist(list *mSpanList, now, limit uint64) uintptr { var sumreleased uintptr for s := list.first; s != nil; s = s.next { - if (now-uint64(s.unusedsince)) > limit && s.npreleased != s.npages { - start := s.base() - end := start + s.npages<<_PageShift - if physPageSize > _PageSize { - // We can only release pages in - // physPageSize blocks, so round start - // and end in. (Otherwise, madvise - // will round them *out* and release - // more memory than we want.) - start = (start + physPageSize - 1) &^ (physPageSize - 1) - end &^= physPageSize - 1 - if end <= start { - // start and end don't span a - // whole physical page. - continue - } - } - len := end - start - - released := len - (s.npreleased << _PageShift) - if physPageSize > _PageSize && released == 0 { + if (now-uint64(s.unusedsince)) <= limit || s.npreleased == s.npages { + continue + } + start := s.base() + end := start + s.npages<<_PageShift + if physPageSize > _PageSize { + // We can only release pages in + // physPageSize blocks, so round start + // and end in. (Otherwise, madvise + // will round them *out* and release + // more memory than we want.) + start = (start + physPageSize - 1) &^ (physPageSize - 1) + end &^= physPageSize - 1 + if end <= start { + // start and end don't span a + // whole physical page. continue } - memstats.heap_released += uint64(released) - sumreleased += released - s.npreleased = len >> _PageShift - sysUnused(unsafe.Pointer(start), len) } + len := end - start + + released := len - (s.npreleased << _PageShift) + if physPageSize > _PageSize && released == 0 { + continue + } + memstats.heap_released += uint64(released) + sumreleased += released + s.npreleased = len >> _PageShift + sysUnused(unsafe.Pointer(start), len) } return sumreleased } diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index dac4de4985..83e35f4e27 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -208,45 +208,46 @@ func sysargs(argc int32, argv **byte) { // now argv+n is auxv auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) - if sysauxv(auxv[:]) == 0 { - // In some situations we don't get a loader-provided - // auxv, such as when loaded as a library on Android. - // Fall back to /proc/self/auxv. - fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) - if fd < 0 { - // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to - // try using mincore to detect the physical page size. - // mincore should return EINVAL when address is not a multiple of system page size. - const size = 256 << 10 // size of memory region to allocate - p := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) - if uintptr(p) < 4096 { - return - } - var n uintptr - for n = 4 << 10; n < size; n <<= 1 { - err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) - if err == 0 { - physPageSize = n - break - } - } - if physPageSize == 0 { - physPageSize = size - } - munmap(p, size) + if sysauxv(auxv[:]) != 0 { + return + } + // In some situations we don't get a loader-provided + // auxv, such as when loaded as a library on Android. + // Fall back to /proc/self/auxv. + fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) + if fd < 0 { + // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to + // try using mincore to detect the physical page size. + // mincore should return EINVAL when address is not a multiple of system page size. + const size = 256 << 10 // size of memory region to allocate + p := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) + if uintptr(p) < 4096 { return } - var buf [128]uintptr - n := read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) - closefd(fd) - if n < 0 { - return + var n uintptr + for n = 4 << 10; n < size; n <<= 1 { + err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) + if err == 0 { + physPageSize = n + break + } + } + if physPageSize == 0 { + physPageSize = size } - // Make sure buf is terminated, even if we didn't read - // the whole file. - buf[len(buf)-2] = _AT_NULL - sysauxv(buf[:]) + munmap(p, size) + return + } + var buf [128]uintptr + n = read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) + closefd(fd) + if n < 0 { + return } + // Make sure buf is terminated, even if we didn't read + // the whole file. + buf[len(buf)-2] = _AT_NULL + sysauxv(buf[:]) } func sysauxv(auxv []uintptr) int { diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 43bfdd7a1e..2a7acb7797 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -244,36 +244,37 @@ func freedefer(d *_defer) { freedeferfn() } sc := deferclass(uintptr(d.siz)) - if sc < uintptr(len(p{}.deferpool)) { - pp := getg().m.p.ptr() - if len(pp.deferpool[sc]) == cap(pp.deferpool[sc]) { - // Transfer half of local cache to the central cache. - // - // Take this slow path on the system stack so - // we don't grow freedefer's stack. - systemstack(func() { - var first, last *_defer - for len(pp.deferpool[sc]) > cap(pp.deferpool[sc])/2 { - n := len(pp.deferpool[sc]) - d := pp.deferpool[sc][n-1] - pp.deferpool[sc][n-1] = nil - pp.deferpool[sc] = pp.deferpool[sc][:n-1] - if first == nil { - first = d - } else { - last.link = d - } - last = d + if sc >= uintptr(len(p{}.deferpool)) { + return + } + pp := getg().m.p.ptr() + if len(pp.deferpool[sc]) == cap(pp.deferpool[sc]) { + // Transfer half of local cache to the central cache. + // + // Take this slow path on the system stack so + // we don't grow freedefer's stack. + systemstack(func() { + var first, last *_defer + for len(pp.deferpool[sc]) > cap(pp.deferpool[sc])/2 { + n := len(pp.deferpool[sc]) + d := pp.deferpool[sc][n-1] + pp.deferpool[sc][n-1] = nil + pp.deferpool[sc] = pp.deferpool[sc][:n-1] + if first == nil { + first = d + } else { + last.link = d } - lock(&sched.deferlock) - last.link = sched.deferpool[sc] - sched.deferpool[sc] = first - unlock(&sched.deferlock) - }) - } - *d = _defer{} - pp.deferpool[sc] = append(pp.deferpool[sc], d) + last = d + } + lock(&sched.deferlock) + last.link = sched.deferpool[sc] + sched.deferpool[sc] = first + unlock(&sched.deferlock) + }) } + *d = _defer{} + pp.deferpool[sc] = append(pp.deferpool[sc], d) } // Separate function so that it can split stack. diff --git a/src/runtime/stack.go b/src/runtime/stack.go index d353329a39..4e60e80863 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -578,29 +578,30 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f if stackDebug >= 4 { print(" ", add(scanp, i*sys.PtrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*sys.PtrSize))), " # ", i, " ", bv.bytedata[i/8], "\n") } - if ptrbit(&bv, i) == 1 { - pp := (*uintptr)(add(scanp, i*sys.PtrSize)) - retry: - p := *pp - if f.valid() && 0 < p && p < minLegalPointer && debug.invalidptr != 0 { - // Looks like a junk value in a pointer slot. - // Live analysis wrong? - getg().m.traceback = 2 - print("runtime: bad pointer in frame ", funcname(f), " at ", pp, ": ", hex(p), "\n") - throw("invalid pointer found on stack") + if ptrbit(&bv, i) != 1 { + continue + } + pp := (*uintptr)(add(scanp, i*sys.PtrSize)) + retry: + p := *pp + if f.valid() && 0 < p && p < minLegalPointer && debug.invalidptr != 0 { + // Looks like a junk value in a pointer slot. + // Live analysis wrong? + getg().m.traceback = 2 + print("runtime: bad pointer in frame ", funcname(f), " at ", pp, ": ", hex(p), "\n") + throw("invalid pointer found on stack") + } + if minp <= p && p < maxp { + if stackDebug >= 3 { + print("adjust ptr ", hex(p), " ", funcname(f), "\n") } - if minp <= p && p < maxp { - if stackDebug >= 3 { - print("adjust ptr ", hex(p), " ", funcname(f), "\n") - } - if useCAS { - ppu := (*unsafe.Pointer)(unsafe.Pointer(pp)) - if !atomic.Casp1(ppu, unsafe.Pointer(p), unsafe.Pointer(p+delta)) { - goto retry - } - } else { - *pp = p + delta + if useCAS { + ppu := (*unsafe.Pointer)(unsafe.Pointer(pp)) + if !atomic.Casp1(ppu, unsafe.Pointer(p), unsafe.Pointer(p+delta)) { + goto retry } + } else { + *pp = p + delta } } } diff --git a/src/text/tabwriter/tabwriter.go b/src/text/tabwriter/tabwriter.go index 752c9b8e9f..c17cef8bd9 100644 --- a/src/text/tabwriter/tabwriter.go +++ b/src/text/tabwriter/tabwriter.go @@ -333,52 +333,53 @@ func (b *Writer) format(pos0 int, line0, line1 int) (pos int) { for this := line0; this < line1; this++ { line := b.lines[this] - if column < len(line)-1 { - // cell exists in this column => this line - // has more cells than the previous line - // (the last cell per line is ignored because cells are - // tab-terminated; the last cell per line describes the - // text before the newline/formfeed and does not belong - // to a column) - - // print unprinted lines until beginning of block - pos = b.writeLines(pos, line0, this) - line0 = this - - // column block begin - width := b.minwidth // minimal column width - discardable := true // true if all cells in this column are empty and "soft" - for ; this < line1; this++ { - line = b.lines[this] - if column < len(line)-1 { - // cell exists in this column - c := line[column] - // update width - if w := c.width + b.padding; w > width { - width = w - } - // update discardable - if c.width > 0 || c.htab { - discardable = false - } - } else { - break + if column >= len(line)-1 { + continue + } + // cell exists in this column => this line + // has more cells than the previous line + // (the last cell per line is ignored because cells are + // tab-terminated; the last cell per line describes the + // text before the newline/formfeed and does not belong + // to a column) + + // print unprinted lines until beginning of block + pos = b.writeLines(pos, line0, this) + line0 = this + + // column block begin + width := b.minwidth // minimal column width + discardable := true // true if all cells in this column are empty and "soft" + for ; this < line1; this++ { + line = b.lines[this] + if column < len(line)-1 { + // cell exists in this column + c := line[column] + // update width + if w := c.width + b.padding; w > width { + width = w } + // update discardable + if c.width > 0 || c.htab { + discardable = false + } + } else { + break } - // column block end - - // discard empty columns if necessary - if discardable && b.flags&DiscardEmptyColumns != 0 { - width = 0 - } + } + // column block end - // format and print all columns to the right of this column - // (we know the widths of this column and all columns to the left) - b.widths = append(b.widths, width) // push width - pos = b.format(pos, line0, this) - b.widths = b.widths[0 : len(b.widths)-1] // pop width - line0 = this + // discard empty columns if necessary + if discardable && b.flags&DiscardEmptyColumns != 0 { + width = 0 } + + // format and print all columns to the right of this column + // (we know the widths of this column and all columns to the left) + b.widths = append(b.widths, width) // push width + pos = b.format(pos, line0, this) + b.widths = b.widths[0 : len(b.widths)-1] // pop width + line0 = this } // print unprinted lines until end -- cgit v1.3 From 3beaf26e4fbf1bfd166fc3b5b7584a58b11e726c Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 22 Oct 2017 21:37:05 -0400 Subject: runtime: remove write barriers from newstack, gogo Currently, newstack and gogo have write barriers for maintaining the context register saved in g.sched.ctxt. This is troublesome, because newstack can be called from go:nowritebarrierrec places that can't allow write barriers. It happens to be benign because g.sched.ctxt will always be nil on entry to newstack *and* it so happens the incoming ctxt will also always be nil in these contexts (I think/hope), but this is playing with fire. It's also desirable to mark newstack go:nowritebarrierrec to prevent any other, non-benign write barriers from creeping in, but we can't do that right now because of this one write barrier. Fix all of this by observing that g.sched.ctxt is really just a saved live pointer register. Hence, we can shade it when we scan g's stack and otherwise move it back and forth between the actual context register and g.sched.ctxt without write barriers. This means we can save it in morestack along with all of the other g.sched, eliminate the save from newstack along with its troublesome write barrier, and eliminate the shenanigans in gogo to invoke the write barrier when restoring it. Once we've done all of this, we can mark newstack go:nowritebarrierrec. Fixes #22385. For #22460. Change-Id: I43c24958e3f6785b53c1350e1e83c2844e0d1522 Reviewed-on: https://go-review.googlesource.com/72553 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Rick Hudson Reviewed-by: Cherry Zhang --- src/runtime/asm_386.s | 16 +--------------- src/runtime/asm_amd64.s | 16 +--------------- src/runtime/asm_amd64p32.s | 16 +--------------- src/runtime/asm_arm.s | 18 ++---------------- src/runtime/asm_arm64.s | 17 ++--------------- src/runtime/asm_mips64x.s | 18 +++--------------- src/runtime/asm_mipsx.s | 18 +++--------------- src/runtime/asm_ppc64x.s | 17 ++--------------- src/runtime/asm_s390x.s | 18 +++--------------- src/runtime/mgcmark.go | 7 +++++++ src/runtime/runtime2.go | 18 ++++++++++-------- src/runtime/stack.go | 12 ++++++------ 12 files changed, 41 insertions(+), 150 deletions(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s index ef82756397..15d9ce9fdf 100644 --- a/src/runtime/asm_386.s +++ b/src/runtime/asm_386.s @@ -362,18 +362,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $8-4 MOVL buf+0(FP), BX // gobuf - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVL gobuf_ctxt(BX), DX - TESTL DX, DX - JZ nilctxt - LEAL gobuf_ctxt(BX), AX - MOVL AX, 0(SP) - MOVL $0, 4(SP) - CALL runtime·writebarrierptr_prewrite(SB) - MOVL buf+0(FP), BX - -nilctxt: MOVL gobuf_g(BX), DX MOVL 0(DX), CX // make sure g != nil get_tls(CX) @@ -536,7 +524,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 MOVL SI, (g_sched+gobuf_g)(SI) LEAL 4(SP), AX // f's SP MOVL AX, (g_sched+gobuf_sp)(SI) - // newstack will fill gobuf.ctxt. + MOVL DX, (g_sched+gobuf_ctxt)(SI) // Call newstack on m->g0's stack. MOVL m_g0(BX), BP @@ -544,10 +532,8 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 MOVL (g_sched+gobuf_sp)(BP), AX MOVL -4(AX), BX // fault if CALL would, before smashing SP MOVL AX, SP - PUSHL DX // ctxt argument CALL runtime·newstack(SB) MOVL $0, 0x1003 // crash if newstack returns - POPL DX // keep balance check happy RET TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0 diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 7c5e8e9ada..2ac879c31d 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -304,18 +304,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-8 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVQ buf+0(FP), BX // gobuf - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVQ gobuf_ctxt(BX), AX - TESTQ AX, AX - JZ nilctxt - LEAQ gobuf_ctxt(BX), AX - MOVQ AX, 0(SP) - MOVQ $0, 8(SP) - CALL runtime·writebarrierptr_prewrite(SB) - MOVQ buf+0(FP), BX - -nilctxt: MOVQ gobuf_g(BX), DX MOVQ 0(DX), CX // make sure g != nil get_tls(CX) @@ -482,16 +470,14 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 LEAQ 8(SP), AX // f's SP MOVQ AX, (g_sched+gobuf_sp)(SI) MOVQ BP, (g_sched+gobuf_bp)(SI) - // newstack will fill gobuf.ctxt. + MOVQ DX, (g_sched+gobuf_ctxt)(SI) // Call newstack on m->g0's stack. MOVQ m_g0(BX), BX MOVQ BX, g(CX) MOVQ (g_sched+gobuf_sp)(BX), SP - PUSHQ DX // ctxt argument CALL runtime·newstack(SB) MOVQ $0, 0x1003 // crash if newstack returns - POPQ DX // keep balance check happy RET // morestack but not preserving ctxt. diff --git a/src/runtime/asm_amd64p32.s b/src/runtime/asm_amd64p32.s index c80a563bda..b7fcf2376e 100644 --- a/src/runtime/asm_amd64p32.s +++ b/src/runtime/asm_amd64p32.s @@ -198,18 +198,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $8-4 MOVL buf+0(FP), BX // gobuf - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVL gobuf_ctxt(BX), DX - TESTL DX, DX - JZ nilctxt - LEAL gobuf_ctxt(BX), AX - MOVL AX, 0(SP) - MOVL $0, 4(SP) - CALL runtime·writebarrierptr_prewrite(SB) - MOVL buf+0(FP), BX - -nilctxt: MOVL gobuf_g(BX), DX MOVL 0(DX), CX // make sure g != nil get_tls(CX) @@ -368,16 +356,14 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 MOVL SI, (g_sched+gobuf_g)(SI) LEAL 8(SP), AX // f's SP MOVL AX, (g_sched+gobuf_sp)(SI) - // newstack will fill gobuf.ctxt. + MOVL DX, (g_sched+gobuf_ctxt)(SI) // Call newstack on m->g0's stack. MOVL m_g0(BX), BX MOVL BX, g(CX) MOVL (g_sched+gobuf_sp)(BX), SP - PUSHQ DX // ctxt argument CALL runtime·newstack(SB) MOVL $0, 0x1003 // crash if newstack returns - POPQ DX // keep balance check happy RET // morestack trampolines diff --git a/src/runtime/asm_arm.s b/src/runtime/asm_arm.s index 47fa565c52..caa96cc4b3 100644 --- a/src/runtime/asm_arm.s +++ b/src/runtime/asm_arm.s @@ -227,19 +227,6 @@ TEXT runtime·gosave(SB),NOSPLIT,$-4-4 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB),NOSPLIT,$8-4 MOVW buf+0(FP), R1 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVW gobuf_ctxt(R1), R0 - CMP $0, R0 - B.EQ nilctxt - MOVW $gobuf_ctxt(R1), R0 - MOVW R0, 4(R13) - MOVW $0, R0 - MOVW R0, 8(R13) - BL runtime·writebarrierptr_prewrite(SB) - MOVW buf+0(FP), R1 - -nilctxt: MOVW gobuf_g(R1), R0 BL setg<>(SB) @@ -412,7 +399,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-4-0 MOVW R13, (g_sched+gobuf_sp)(g) MOVW LR, (g_sched+gobuf_pc)(g) MOVW R3, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVW R7, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's caller. @@ -426,8 +413,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-4-0 BL setg<>(SB) MOVW (g_sched+gobuf_sp)(g), R13 MOVW $0, R0 - MOVW.W R0, -8(R13) // create a call frame on g0 - MOVW R7, 4(R13) // ctxt argument + MOVW.W R0, -4(R13) // create a call frame on g0 (saved LR) BL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s index e4b2c37038..b2aff1aab7 100644 --- a/src/runtime/asm_arm64.s +++ b/src/runtime/asm_arm64.s @@ -122,18 +122,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $-8-8 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $24-8 MOVD buf+0(FP), R5 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVD gobuf_ctxt(R5), R0 - CMP $0, R0 - BEQ nilctxt - MOVD $gobuf_ctxt(R5), R0 - MOVD R0, 8(RSP) - MOVD ZR, 16(RSP) - BL runtime·writebarrierptr_prewrite(SB) - MOVD buf+0(FP), R5 - -nilctxt: MOVD gobuf_g(R5), g BL runtime·save_g(SB) @@ -289,7 +277,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-8-0 MOVD R0, (g_sched+gobuf_sp)(g) MOVD LR, (g_sched+gobuf_pc)(g) MOVD R3, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVD R26, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's callers. @@ -303,8 +291,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-8-0 BL runtime·save_g(SB) MOVD (g_sched+gobuf_sp)(g), R0 MOVD R0, RSP - MOVD.W $0, -16(RSP) // create a call frame on g0 - MOVD R26, 8(RSP) // ctxt argument + MOVD.W $0, -16(RSP) // create a call frame on g0 (saved LR; keep 16-aligned) BL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s index 4902d04640..3510853804 100644 --- a/src/runtime/asm_mips64x.s +++ b/src/runtime/asm_mips64x.s @@ -108,17 +108,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $-8-8 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVV buf+0(FP), R3 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVV gobuf_ctxt(R3), R1 - BEQ R1, nilctxt - MOVV $gobuf_ctxt(R3), R1 - MOVV R1, 8(R29) - MOVV R0, 16(R29) - JAL runtime·writebarrierptr_prewrite(SB) - MOVV buf+0(FP), R3 - -nilctxt: MOVV gobuf_g(R3), g // make sure g is not nil JAL runtime·save_g(SB) @@ -260,7 +249,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-8-0 MOVV R29, (g_sched+gobuf_sp)(g) MOVV R31, (g_sched+gobuf_pc)(g) MOVV R3, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVV REGCTXT, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's caller. @@ -273,9 +262,8 @@ TEXT runtime·morestack(SB),NOSPLIT,$-8-0 JAL runtime·save_g(SB) MOVV (g_sched+gobuf_sp)(g), R29 // Create a stack frame on g0 to call newstack. - MOVV R0, -16(R29) // Zero saved LR in frame - ADDV $-16, R29 - MOVV REGCTXT, 8(R29) // ctxt argument + MOVV R0, -8(R29) // Zero saved LR in frame + ADDV $-8, R29 JAL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/asm_mipsx.s b/src/runtime/asm_mipsx.s index 82e01b0bac..334f259186 100644 --- a/src/runtime/asm_mipsx.s +++ b/src/runtime/asm_mipsx.s @@ -109,17 +109,6 @@ TEXT runtime·gosave(SB),NOSPLIT,$-4-4 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB),NOSPLIT,$8-4 MOVW buf+0(FP), R3 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVW gobuf_ctxt(R3), R1 - BEQ R1, nilctxt - MOVW $gobuf_ctxt(R3), R1 - MOVW R1, 4(R29) - MOVW R0, 8(R29) - JAL runtime·writebarrierptr_prewrite(SB) - MOVW buf+0(FP), R3 - -nilctxt: MOVW gobuf_g(R3), g // make sure g is not nil JAL runtime·save_g(SB) @@ -261,7 +250,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-4-0 MOVW R29, (g_sched+gobuf_sp)(g) MOVW R31, (g_sched+gobuf_pc)(g) MOVW R3, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVW REGCTXT, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's caller. @@ -274,9 +263,8 @@ TEXT runtime·morestack(SB),NOSPLIT,$-4-0 JAL runtime·save_g(SB) MOVW (g_sched+gobuf_sp)(g), R29 // Create a stack frame on g0 to call newstack. - MOVW R0, -8(R29) // Zero saved LR in frame - ADDU $-8, R29 - MOVW REGCTXT, 4(R29) // ctxt argument + MOVW R0, -4(R29) // Zero saved LR in frame + ADDU $-4, R29 JAL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index 40ad1010a9..2f2a4a7b04 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -133,18 +133,6 @@ TEXT runtime·gosave(SB), NOSPLIT|NOFRAME, $0-8 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVD buf+0(FP), R5 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVD gobuf_ctxt(R5), R3 - CMP R0, R3 - BEQ nilctxt - MOVD $gobuf_ctxt(R5), R3 - MOVD R3, FIXED_FRAME+0(R1) - MOVD R0, FIXED_FRAME+8(R1) - BL runtime·writebarrierptr_prewrite(SB) - MOVD buf+0(FP), R5 - -nilctxt: MOVD gobuf_g(R5), g // make sure g is not nil BL runtime·save_g(SB) @@ -317,7 +305,7 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0 MOVD LR, R8 MOVD R8, (g_sched+gobuf_pc)(g) MOVD R5, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVD R11, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's caller. @@ -329,8 +317,7 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0 MOVD m_g0(R7), g BL runtime·save_g(SB) MOVD (g_sched+gobuf_sp)(g), R1 - MOVDU R0, -(FIXED_FRAME+8)(R1) // create a call frame on g0 - MOVD R11, FIXED_FRAME+0(R1) // ctxt argument + MOVDU R0, -(FIXED_FRAME+0)(R1) // create a call frame on g0 BL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s index 241be17842..524b866b21 100644 --- a/src/runtime/asm_s390x.s +++ b/src/runtime/asm_s390x.s @@ -116,17 +116,6 @@ TEXT runtime·gosave(SB), NOSPLIT, $-8-8 // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVD buf+0(FP), R5 - - // If ctxt is not nil, invoke deletion barrier before overwriting. - MOVD gobuf_ctxt(R5), R1 - CMPBEQ R1, $0, nilctxt - MOVD $gobuf_ctxt(R5), R1 - MOVD R1, 8(R15) - MOVD R0, 16(R15) - BL runtime·writebarrierptr_prewrite(SB) - MOVD buf+0(FP), R5 - -nilctxt: MOVD gobuf_g(R5), g // make sure g is not nil BL runtime·save_g(SB) @@ -272,7 +261,7 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0 MOVD LR, R8 MOVD R8, (g_sched+gobuf_pc)(g) MOVD R5, (g_sched+gobuf_lr)(g) - // newstack will fill gobuf.ctxt. + MOVD R12, (g_sched+gobuf_ctxt)(g) // Called from f. // Set m->morebuf to f's caller. @@ -285,9 +274,8 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0 BL runtime·save_g(SB) MOVD (g_sched+gobuf_sp)(g), R15 // Create a stack frame on g0 to call newstack. - MOVD $0, -16(R15) // Zero saved LR in frame - SUB $16, R15 - MOVD R12, 8(R15) // ctxt argument + MOVD $0, -8(R15) // Zero saved LR in frame + SUB $8, R15 BL runtime·newstack(SB) // Not reached, but make sure the return PC from the call to newstack diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index ed256efc80..ce697e5809 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -770,6 +770,13 @@ func scanstack(gp *g, gcw *gcWork) { shrinkstack(gp) } + // Scan the saved context register. This is effectively a live + // register that gets moved back and forth between the + // register and sched.ctxt without a write barrier. + if gp.sched.ctxt != nil { + scanblock(uintptr(unsafe.Pointer(&gp.sched.ctxt)), sys.PtrSize, &oneptrmask[0], gcw) + } + // Scan the stack. var cache pcvalueCache scanframe := func(frame *stkframe, unused unsafe.Pointer) bool { diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index ca796169fe..a79faba8ce 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -254,17 +254,19 @@ type gobuf struct { // The offsets of sp, pc, and g are known to (hard-coded in) libmach. // // ctxt is unusual with respect to GC: it may be a - // heap-allocated funcval so write require a write barrier, - // but gobuf needs to be cleared from assembly. We take - // advantage of the fact that the only path that uses a - // non-nil ctxt is morestack. As a result, gogo is the only - // place where it may not already be nil, so gogo uses an - // explicit write barrier. Everywhere else that resets the - // gobuf asserts that ctxt is already nil. + // heap-allocated funcval, so GC needs to track it, but it + // needs to be set and cleared from assembly, where it's + // difficult to have write barriers. However, ctxt is really a + // saved, live register, and we only ever exchange it between + // the real register and the gobuf. Hence, we treat it as a + // root during stack scanning, which means assembly that saves + // and restores it doesn't need write barriers. It's still + // typed as a pointer so that any other writes from Go get + // write barriers. sp uintptr pc uintptr g guintptr - ctxt unsafe.Pointer // this has to be a pointer so that gc scans it + ctxt unsafe.Pointer ret sys.Uintreg lr uintptr bp uintptr // for GOEXPERIMENT=framepointer diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 4e60e80863..89458b7ff6 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -913,9 +913,12 @@ func round2(x int32) int32 { // g->atomicstatus will be Grunning or Gscanrunning upon entry. // If the GC is trying to stop this g then it will set preemptscan to true. // -// ctxt is the value of the context register on morestack. newstack -// will write it to g.sched.ctxt. -func newstack(ctxt unsafe.Pointer) { +// This must be nowritebarrierrec because it can be called as part of +// stack growth from other nowritebarrierrec functions, but the +// compiler doesn't check this. +// +//go:nowritebarrierrec +func newstack() { thisg := getg() // TODO: double check all gp. shouldn't be getg(). if thisg.m.morebuf.g.ptr().stackguard0 == stackFork { @@ -929,9 +932,6 @@ func newstack(ctxt unsafe.Pointer) { } gp := thisg.m.curg - // Write ctxt to gp.sched. We do this here instead of in - // morestack so it has the necessary write barrier. - gp.sched.ctxt = ctxt if thisg.m.curg.throwsplit { // Update syscallsp, syscallpc in case traceback uses them. -- cgit v1.3 From 4671da0414b31c7bd234e96b5af414fecb79e861 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 22 Nov 2017 15:29:03 -0500 Subject: runtime: print runtime frames in throwsplit trace newstack manually prints the stack trace if we try to grow the stack when throwsplit is set. However, the default behavior is to omit runtime frames. Since runtime frames can be critical to understanding this crash, this change fixes this traceback to include them. Updates #21431. Change-Id: I5aa43f43aa2f10a8de7d67bcec743427be3a3b5d Reviewed-on: https://go-review.googlesource.com/79518 Run-TryBot: Austin Clements Reviewed-by: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/runtime/stack.go | 1 + 1 file changed, 1 insertion(+) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 89458b7ff6..eb0716c18d 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -942,6 +942,7 @@ func newstack() { "\tmorebuf={pc:", hex(morebuf.pc), " sp:", hex(morebuf.sp), " lr:", hex(morebuf.lr), "}\n", "\tsched={pc:", hex(gp.sched.pc), " sp:", hex(gp.sched.sp), " lr:", hex(gp.sched.lr), " ctxt:", gp.sched.ctxt, "}\n") + thisg.m.traceback = 2 // Include runtime frames traceback(morebuf.pc, morebuf.sp, morebuf.lr, gp) throw("runtime: stack split at bad time") } -- cgit v1.3