Issue 1:
all.bash fails on fedora-vm,

uname -a
Linux fedora-amd64.localdomain 4.2.8-200.fc22.x86_64 #1 SMP Tue Dec 15 16:50:23 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

git rev-parse HEAD
acc7161320038ee6377d589890526cd11912b4e8

ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7851
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

with the following dying message:

--- FAIL: TestStackBarrierProfiling (0.02s)
pprof_test.go:363: subprocess failed with exit status 2:
SIGTRAP: trace trap
PC=0x459cfd m=2

goroutine 0 [idle]:
runtime.morestack()
/go/src/runtime/asm_amd64.s:331 +0x1d

goroutine 4 [running]:
runtime.systemstack_switch()
/go/src/runtime/asm_amd64.s:245 fp=0xc8200414f8 sp=0xc8200414f0
runtime.gcMarkTermination()
/go/src/runtime/mgc.go:1255 +0x3a9 fp=0xc820041748 sp=0xc8200414f8
runtime.gcMarkDone()
/go/src/runtime/mgc.go:1141 +0x286 fp=0xc820041768 sp=0xc820041748
runtime.gcBgMarkWorker(0xc82001c000)
/go/src/runtime/mgc.go:1465 +0x4d8 fp=0xc8200417d8 sp=0xc820041768
runtime.goexit()
/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc8200417e0 sp=0xc8200417d8
created by runtime.gcBgMarkStartWorkers
/go/src/runtime/mgc.go:1335 +0x93

goroutine 1 [chan receive]:
testing.RunTests(0x610ac0, 0x6b03e0, 0x8, 0x8, 0x7f2e00000001)
/go/src/testing/testing.go:583 +0x8d2
testing.(*M).Run(0xc8200bef38, 0x408ee7)
/go/src/testing/testing.go:515 +0x81
main.main()
runtime/pprof/_test/_testmain.go:70 +0x117

goroutine 19 [runnable]:
runtime/pprof_test.deepStack(0x1c1, 0xc820161800)
/go/src/runtime/pprof/pprof_test.go:393 +0x52
runtime/pprof_test.deepStack(0x1c2, 0xc820161400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c3, 0xc820161000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c4, 0xc820160c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c5, 0xc820160800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c6, 0xc820160400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c7, 0xc820160000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c8, 0xc82015fc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1c9, 0xc82015f800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ca, 0xc82015f400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1cb, 0xc82015f000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1cc, 0xc82015ec00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1cd, 0xc82015e800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ce, 0xc82015e400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1cf, 0xc82015e000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d0, 0xc82015dc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d1, 0xc82015d800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d2, 0xc82015d400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d3, 0xc82015d000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d4, 0xc82015cc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d5, 0xc82015c800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d6, 0xc82015c400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d7, 0xc82015c000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d8, 0xc82015bc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1d9, 0xc82015b800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1da, 0xc82015b400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1db, 0xc82015b000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1dc, 0xc82015ac00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1dd, 0xc82015a800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1de, 0xc82015a400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1df, 0xc82015a000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e0, 0xc820159c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e1, 0xc820159800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e2, 0xc820159400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e3, 0xc820159000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e4, 0xc820158c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e5, 0xc820158800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e6, 0xc820158400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e7, 0xc820158000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e8, 0xc820157c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1e9, 0xc820157800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ea, 0xc820157400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1eb, 0xc820157000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ec, 0xc820156c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ed, 0xc820156800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ee, 0xc820156400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ef, 0xc820156000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f0, 0xc820155c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f1, 0xc820155800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f2, 0xc820155400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f3, 0xc820155000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f4, 0xc820154c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f5, 0xc820154800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f6, 0xc820154400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f7, 0xc820154000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f8, 0xc820153c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1f9, 0xc820153800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1fa, 0xc820153400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1fb, 0xc820153000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1fc, 0xc820152c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1fd, 0xc820152800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1fe, 0xc820152400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x1ff, 0xc820152000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x200, 0xc820151c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x201, 0xc820151800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x202, 0xc820151400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x203, 0xc820151000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x204, 0xc820150c00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x205, 0xc820150800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x206, 0xc820150400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x207, 0xc820150000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x208, 0xc82014fc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x209, 0xc82014f800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20a, 0xc82014f400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20b, 0xc82014f000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20c, 0xc82014ec00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20d, 0xc82014e800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20e, 0xc82014e400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x20f, 0xc82014e000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x210, 0xc82014dc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x211, 0xc82014d800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x212, 0xc82014d400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x213, 0xc82014d000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x214, 0xc82014cc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x215, 0xc82014c800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x216, 0xc82014c400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x217, 0xc82014c000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x218, 0xc82014bc00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x219, 0xc82014b800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x21a, 0xc82014b400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x21b, 0xc82014b000)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x21c, 0xc82014ac00)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x21d, 0xc82014a800)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
runtime/pprof_test.deepStack(0x21e, 0xc82014a400)
/go/src/runtime/pprof/pprof_test.go:394 +0x90
created by testing.RunTests
/go/src/testing/testing.go:582 +0x892

goroutine 20 [runnable]:
runtime/pprof.profileWriter(0x7f2e60199650, 0xc82009a310)
/go/src/runtime/pprof/pprof.go:597
created by runtime/pprof.StartCPUProfile
/go/src/runtime/pprof/pprof.go:593 +0x145

rax 0xf80
rbx 0xc82002a400
rcx 0xc820000900
rdx 0x0
rdi 0x42eec0
rsi 0xc820000900
rbp 0x2
rsp 0xc82003af78
r8 0xc820000f00
r9 0x47ae147ae147ae15
r10 0x4d9e5
r11 0x203
r12 0x42f150
r13 0x60fe08
r14 0x0
r15 0x8
rip 0x459cfd
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
FAIL

Issue 2:
While stress testing TestStackBarrierProfiling at 54bd5a7 on master, I got a segfault in sigtrampgo in signal_linux.go because g != nil, but g.m == nil.

I've saved the binary and core file. Here is some preliminary digging through the core:

Core was generated by `./pprof.test -test.run=TestStackBarrierProfiling'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000000000043de2e in runtime.sigtrampgo (sig=11, info=0xc820061bf0,
ctx=0xc820061ac0) at /home/austin/go.dev/src/runtime/signal_linux.go:20
20 setg(g.m.gsignal)
Loading Go Runtime support.
(gdb) bt
#0 0x000000000043de2e in runtime.sigtrampgo (sig=11, info=0xc820061bf0,
ctx=0xc820061ac0) at /home/austin/go.dev/src/runtime/signal_linux.go:20
#1 0x000000000045c93b in runtime.sigtramp ()
at /home/austin/go.dev/src/runtime/sys_linux_amd64.s:234
#2 0x000000000045c940 in runtime.sigtramp ()
at /home/austin/go.dev/src/runtime/sys_linux_amd64.s:235
#3 0x0000000000000001 in ?? ()
#4 0x0000000000000000 in ?? ()
(gdb) print/x *g
$5 = {stack = {lo = 0xc820092000, hi = 0xc820092800},
stackguard0 = 0xfffffffffffffade, stackguard1 = 0xffffffffffffffff,
_panic = 0x0, _defer = 0x0, m = 0x0, stackAlloc = 0x1000, sched = {sp = 0x0,
pc = 0x459140, g = 0xc820001200, ctxt = 0x0, ret = 0x0, lr = 0x0,
bp = 0x4}, syscallsp = 0x0, syscallpc = 0x0, stkbar = []runtime.stkbar,
stkbarPos = 0x0, stktopsp = 0xc8200927d8, param = 0x0, atomicstatus = 0x2,
stackLock = 0x0, goid = 0x6, waitsince = 0x0,
waitreason = "GC worker (idle)", schedlink = 0x0, preempt = 0x1,
paniconfault = 0x0, preemptscan = 0x0, gcscandone = 0x1, gcscanvalid = 0x0,
throwsplit = 0x0, raceignore = 0x0, sysblocktraced = 0x0,
sysexitticks = 0x0, sysexitseq = 0x0, lockedm = 0x0, sig = 0x0,
writebuf = []uint8, sigcode0 = 0x0, sigcode1 = 0x0, sigpc = 0x0,
gopc = 0x418163, startpc = 0x4181d0, racectx = 0x0, waiting = 0x0,
gcAssistBytes = 0x0}
(gdb) x/i g.sched.pc
0x459140 <runtime.systemstack_switch>: retq
(gdb) x/i g.gopc
0x418163 <runtime.gcBgMarkStartWorkers+147>:
lea 0x2a4c96(%rip),%rbx # 0x6bce00 <runtime.work>
(gdb) x/i g.startpc
0x4181d0 <runtime.gcBgMarkWorker>: mov %fs:0xfffffffffffffff8,%rcx

(gdb) print/x *(struct 'runtime.sigcontext'*)(ctx+40)
$11 = {r8 = 0x0, r9 = 0x0, r10 = 0xc82003ef18, r11 = 0x206, r12 = 0x800,
r13 = 0x400, r14 = 0x9, r15 = 0x8, rdi = 0x6bcdb0, rsi = 0x0,
rbp = 0xc820026000, rbx = 0x0, rdx = 0x0, rax = 0xc820001200,
rcx = 0xc820001200, rsp = 0xc820092738, rip = 0x45920d, eflags = 0x10246,
cs = 0x33, gs = 0x0, fs = 0x0, __pad0 = 0x0, err = 0x4, trapno = 0xe,
oldmask = 0x0, cr2 = 0x0, fpstate = 0xc820061c80, __reserved1 = {0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb) x/i $11.rip
0x45920d <runtime.morestack+13>: mov (%rbx),%rsi
(gdb) x/21a $11.rsp
0xc820092738: 0x4189e2 <runtime.gcFlushGCWork+130> 0x417390 <runtime.gcMarkDone+560>
0xc820092748: 0x619060 <runtime.stopTheWorldWithSema.f> 0xffffffff00000001
0xc820092758: 0xffffffff00000001 0x4186a8 <runtime.gcBgMarkWorker+1240>
0xc820092768: 0x0 0x0
0xc820092778: 0xffffffff 0x10
0xc820092788: 0x14 0x0
0xc820092798: 0xffffffff01000000 0xfffffffe
0xc8200927a8: 0x2120869068188 0x0
0xc8200927b8: 0xc820034800 0xc820001200
0xc8200927c8: 0x618e78 <runtime.gcBgMarkWorker.func1.f> 0x45bba1 <runtime.goexit+1>
0xc8200927d8: 0xc820024a00
(gdb) disassemble 'runtime.gcBgMarkWorker'
0x00000000004186a3 <+1235>: callq 0x417160 <runtime.gcMarkDone>
0x00000000004186a8 <+1240>: mov %fs:0xfffffffffffffff8,%rax
(gdb) disassemble 'runtime.gcMarkDone'
0x000000000041738b <+555>: callq 0x418960 <runtime.gcFlushGCWork>
0x0000000000417390 <+560>: callq 0x41a650 <runtime.gcWakeAllAssists>
(gdb) disassemble 'runtime.gcFlushGCWork'
0x00000000004189dd <+125>: callq 0x459290 <runtime.morestack_noctxt>
0x00000000004189e2 <+130>: jmpq 0x418960 <runtime.gcFlushGCWork>

This appears to be a nested signal. The original signal was a SIGSEGV in morestack at MOVQ m_g0(BX), SI because BX (getg().m) is 0. The signal handler then also crashed for the same reason. We clearly tried to grow the stack in gcFlushGCWork (the stack is very small because this test runs in gcstackbarrierall mode), but I'm not sure why there wasn't an M at that point. It may be related to the fact that we've stopped the world in gcMarkDone at that point.

This is relatively easy to reproduce. It happened five times out of 3,000 stress runs on my workstation (which took ~25 minutes).