gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.
MIT License
3.82k stars 265 forks source link

Invalid pointer found on stack #122

Open btracey opened 6 years ago

btracey commented 6 years ago

I reliably get the following kernel panic when running the attached notebook. This is starting the jupyter program new and running the cells in order.

Jupyter program:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import (\n",
    "    \"bufio\"\n",
    "    \"bytes\"\n",
    "    \n",
    "    \"golang.org/x/exp/rand\"\n",
    "    \n",
    "    \"gonum.org/v1/gonum/stat\"\n",
    "    \"gonum.org/v1/gonum/stat/distmv\"\n",
    "    \"gonum.org/v1/gonum/mat\"\n",
    "    \"gonum.org/v1/plot\"\n",
    "    \"gonum.org/v1/plot/plotter\"\n",
    "    \"gonum.org/v1/plot/vg\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "// First, let's generate fake data. Set dimension and number of fake points\n",
    "nDim := 5\n",
    "nSamples := 2000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "// First, let's generate a random positive definite covariance matrix.\n",
    "dat := make([]float64, nDim*nDim)\n",
    "for i := range dat {\n",
    "    dat[i] = rand.Float64()\n",
    "}\n",
    "a := mat.NewDense(nDim, nDim, dat)\n",
    "sigma := mat.NewSymDense(nDim, nil)\n",
    "sigma.SymOuterK(1,a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Construct the multivariate normal distribution.\n",
    "mu := make([]float64, nDim)\n",
    "for i := range mu{\n",
    "    mu[i] = rand.Float64()\n",
    "}\n",
    "dist, ok := distmv.NewNormal(mu, sigma, nil)\n",
    "if !ok{\n",
    "    panic(\"bad covariance matrix\")\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Sample the distribution to get data\n",
    "samples := mat.NewDense(nSamples, nDim, nil)\n",
    "for i := 0; i < nSamples; i++ {\n",
    "    dist.Rand(samples.RawRowView(i))\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Wrap function for plotting as a pdf\n",
    "func displayPlot(p *plot.Plot){\n",
    "    // This seems to be the best way to plot in jupyter at the moment?\n",
    "    w, err := p.WriterTo(8*vg.Inch, 8*vg.Inch, \"pdf\")\n",
    "    if err != nil{\n",
    "        panic(err)\n",
    "    }\n",
    "    var b bytes.Buffer\n",
    "    writer := bufio.NewWriter(&b)\n",
    "    w.WriteTo(writer)\n",
    "    display.JPEG(b.Bytes())\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Plot the first two dimensions\n",
    "pts := make(plotter.XYs, nSamples)\n",
    "for i := range pts{\n",
    "    pts[i].X = samples.At(i,0)\n",
    "    pts[i].Y = samples.At(i,1)\n",
    "}\n",
    "scat, err := plotter.NewScatter(pts)\n",
    "if err != nil{\n",
    "    panic(err)\n",
    "}\n",
    "p, _ := plot.New()\n",
    "p.Add(scat)\n",
    "displayPlot(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.10.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

And the panic:

[I 15:16:44.636 NotebookApp] Adapting to protocol v5.0 for kernel f159b257-788b-47f9-8174-e3d11de271b1
runtime: bad pointer in frame gonum.org/v1/plot.(*Plot).Draw at 0xc42081a118: 0xb
fatal error: invalid pointer found on stack

runtime stack:
runtime.throw(0xb02f530, 0x1e)
    /Users/brendan/gover/go/src/runtime/panic.go:616 +0x81 fp=0x70000caed708 sp=0x70000caed6e8 pc=0xad5ffe1
runtime.adjustpointers(0xc420819c60, 0x70000caed800, 0x70000caedbc0, 0xb186090, 0xb1952a0)
    /Users/brendan/gover/go/src/runtime/stack.go:592 +0x23e fp=0x70000caed778 sp=0x70000caed708 pc=0xad7388e
runtime.adjustframe(0x70000caedad0, 0x70000caedbc0, 0xb1952a0)
    /Users/brendan/gover/go/src/runtime/stack.go:663 +0x325 fp=0x70000caed830 sp=0x70000caed778 pc=0xad73bd5
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420000180, 0x0, 0x0, 0x7fffffff, 0xb03c4e0, 0x70000caedbc0, 0x0, ...)
    /Users/brendan/gover/go/src/runtime/traceback.go:310 +0x12d3 fp=0x70000caedb38 sp=0x70000caed830 pc=0xad7c893
runtime.copystack(0xc420000180, 0x10000, 0x70000caedd01)
    /Users/brendan/gover/go/src/runtime/stack.go:891 +0x26e fp=0x70000caedcf0 sp=0x70000caedb38 pc=0xad746be
runtime.newstack()
    /Users/brendan/gover/go/src/runtime/stack.go:1063 +0x310 fp=0x70000caede80 sp=0x70000caedcf0 pc=0xad74ad0
runtime.morestack()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:480 +0x89 fp=0x70000caede88 sp=0x70000caede80 pc=0xad82749

goroutine 1 [copystack]:
github.com/jung-kurt/gofpdf.MakeFont(0xc4206ae5a0, 0x59, 0xc4206ae6c0, 0x5b, 0xc4206ae420, 0x51, 0x50b8d00, 0x570e050, 0xb028f01, 0xa, ...)
    /Users/brendan/Documents/mygo/src/github.com/jung-kurt/gofpdf/font.go:404 +0xbcb fp=0xc420819208 sp=0xc420819200 pc=0xaf3105b
gonum.org/v1/plot/vg/vgpdf.makeFont(0xc4205c4000, 0x5ed00, 0x7fe00, 0xc420892000, 0x11bd, 0x1e00, 0x1, 0x0, 0x0, 0x0, ...)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/vg/vgpdf/vgpdf.go:398 +0x483 fp=0xc420819380 sp=0xc420819208 pc=0xaf64503
gonum.org/v1/plot/vg/vgpdf.(*Canvas).font(0xc420774050, 0x4024000000000000, 0xb029305, 0xb, 0xc420030960, 0x4045dfa28e867611, 0x3fc7c00000000000)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/vg/vgpdf/vgpdf.go:211 +0x28e fp=0xc420819540 sp=0xc420819380 pc=0xaf6300e
gonum.org/v1/plot/vg/vgpdf.(*Canvas).FillString(0xc420774050, 0x4024000000000000, 0xb029305, 0xb, 0xc420030960, 0x4045dfa28e867611, 0x3fc7c00000000000, 0xc420bf4206, 0x2)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/vg/vgpdf/vgpdf.go:147 +0x94 fp=0xc4208195e0 sp=0xc420819540 pc=0xaf62704
gonum.org/v1/plot/vg/draw.(*Canvas).FillString(0xc42077c990, 0x4024000000000000, 0xb029305, 0xb, 0xc420030960, 0x4045dfa28e867611, 0x3fc7c00000000000, 0xc420bf4206, 0x2)
    <autogenerated>:1 +0xa6 fp=0xc420819638 sp=0xc4208195e0 pc=0xaf79b26
gonum.org/v1/plot/vg/draw.(*Canvas).FillString(0xc42077c9f0, 0x4024000000000000, 0xb029305, 0xb, 0xc420030960, 0x4045dfa28e867611, 0x3fc7c00000000000, 0xc420bf4206, 0x2)
    <autogenerated>:1 +0xa6 fp=0xc420819690 sp=0xc420819638 pc=0xaf79b26
gonum.org/v1/plot/vg/draw.(*Canvas).FillText(0xc420819be8, 0x50b8b20, 0x570f720, 0x4024000000000000, 0xb029305, 0xb, 0xc420030960, 0x0, 0xbfe0000000000000, 0xbff0000000000000, ...)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/vg/draw/canvas.go:639 +0x364 fp=0xc420819758 sp=0xc420819690 pc=0xaf78c04
gonum.org/v1/plot.horizontalAxis.draw(0xc0116acf312122a1, 0x4013c191e7667211, 0x0, 0x0, 0x50b8b20, 0x570f720, 0x4028000000000000, 0xb029305, 0xb, 0xc420030960, ...)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/axis.go:229 +0x291 fp=0xc420819a98 sp=0xc420819758 pc=0xaf7d301
gonum.org/v1/plot.(*Plot).Draw(0xc42048a800, 0xb06ae80, 0xc420774050, 0x0, 0x0, 0x4082000000000000, 0x4082000000000000)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/plot.go:160 +0x389 fp=0xc42081a388 sp=0xc420819a98 pc=0xaf82729
gonum.org/v1/plot.(*Plot).WriterTo(0xc42048a800, 0x4082000000000000, 0x4082000000000000, 0xc42092e881, 0x3, 0x0, 0x0, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/gonum.org/v1/plot/plot.go:445 +0x132 fp=0xc42081a418 sp=0xc42081a388 pc=0xaf852a2
runtime.call128(0xc42077c660, 0xc420684048, 0xc420774000, 0x2800000048)
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:575 +0x52 fp=0xc42081a4a8 sp=0xc42081a418 pc=0x405dfe2
reflect.Value.call(0xb00ac40, 0xc420684040, 0x3293, 0x4d932d9, 0x4, 0xc4203528c0, 0x3, 0x3, 0x196, 0xc, ...)
    /Users/brendan/gover/go/src/reflect/value.go:447 +0x969 fp=0xc42081a768 sp=0xc42081a4a8 pc=0x40d2559
reflect.Value.Call(0xb00ac40, 0xc420684040, 0x3293, 0xc4203528c0, 0x3, 0x3, 0xc420684040, 0x3293, 0xc42092e7b0)
    /Users/brendan/gover/go/src/reflect/value.go:308 +0xa4 fp=0xc42081a7d0 sp=0xc42081a768 pc=0x40d1ad4
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.callxr(0xb00ac40, 0xc420684040, 0x3293, 0xc4203528c0, 0x3, 0x3, 0xc420684018, 0x4c9f880, 0xc420352928)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/call.go:392 +0x71 fp=0xc42081a828 sp=0xc42081a7d0 pc=0x47cb571
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.(*Comp).call_ret2plus.func4(0xc420296780, 0xb00ac40, 0xc420352988, 0x40d6ab4, 0xb00ac40, 0xc42048a800, 0x16)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/call.go:368 +0x1f3 fp=0xc42081a918 sp=0xc42081a828 pc=0x494af33
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.(*Comp).DeclMultiVar0.func1(0xc420296780, 0xb00ac40, 0xc420684040)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/declaration.go:585 +0x3b fp=0xc42081a990 sp=0xc42081a918 pc=0x49a5c5b
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.exec.func1(0xc420296780)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/code.go:170 +0x130 fp=0xc42081aa18 sp=0xc42081a990 pc=0x49a2400
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.(*Comp).funcGeneric.func2.1(0xc42077a160, 0x1, 0x1, 0xc42077a160, 0x0, 0x1)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/function.go:453 +0x118 fp=0xc42081aab0 sp=0xc42081aa18 pc=0x4a0c0e8
reflect.callReflect(0xc4207d3040, 0xc420352c58)
    /Users/brendan/gover/go/src/reflect/value.go:528 +0x331 fp=0xc42081ac38 sp=0xc42081aab0 pc=0x40d3291
reflect.makeFuncStub(0xc42048a800, 0xb00ac40, 0xc420684038, 0xc420684000, 0xc420352f38, 0x40d2559, 0xc4207baed0, 0xc4207d3040, 0xc420684038, 0x800000008, ...)
    /Users/brendan/gover/go/src/reflect/asm_amd64.s:17 +0x33 fp=0xc42081ac58 sp=0xc42081ac38 pc=0x40dd3c3
runtime.call32(0xc4207baed0, 0xc4207d3040, 0xc420684038, 0x800000008)
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:573 +0x3b fp=0xc42081ac88 sp=0xc42081ac58 pc=0x405decb
reflect.Value.call(0xc42057d200, 0xc4207d3040, 0x13, 0x4d932d9, 0x4, 0xc420353070, 0x1, 0x1, 0xafe1320, 0xc420352ff8, ...)
    /Users/brendan/gover/go/src/reflect/value.go:447 +0x969 fp=0xc42081af48 sp=0xc42081ac88 pc=0x40d2559
reflect.Value.Call(0xc42057d200, 0xc4207d3040, 0x13, 0xc420353070, 0x1, 0x1, 0x0, 0x0, 0x0)
    /Users/brendan/gover/go/src/reflect/value.go:308 +0xa4 fp=0xc42081afb0 sp=0xc42081af48 pc=0x40d1ad4
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.callxr(0xc42057d200, 0xc4207d3040, 0x13, 0xc420353070, 0x1, 0x1, 0x0, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/call.go:392 +0x71 fp=0xc42081b008 sp=0xc42081afb0 pc=0x47cb571
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.(*Comp).call1ret0.func69(0xc420296000)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/callnret0.go:1126 +0xe0 fp=0xc42081b098 sp=0xc42081b008 pc=0x4994b30
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.funList.func2(0xc420296000)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/util.go:1329 +0x84 fp=0xc42081b0d0 sp=0xc42081b098 pc=0x4a60224
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.funAsXV.func1(0xc420296000, 0x1, 0xc4207d6d00, 0x0, 0x5c35d90, 0x0, 0x7)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/util.go:671 +0x2f fp=0xc42081b0e8 sp=0xc42081b0d0 pc=0x4a5bb7f
github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast.(*Interp).RunExpr(0xc4201e8380, 0xc4208645f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/cosmos72/gomacro/fast/repl.go:131 +0x164 fp=0xc42081b178 sp=0xc42081b0e8 pc=0x488ccc4
main.doEval(0xc4201e8380, 0xc4205497a0, 0x10a, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:485 +0x265 fp=0xc42081b250 sp=0xc42081b178 pc=0x4b371d5
main.handleExecuteRequest(0xc4201e8380, 0xc4201f7140, 0x20, 0xc42092eb70, 0x8, 0xc4201f7160, 0x20, 0xc42092eb80, 0xf, 0xc42092eb78, ...)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:392 +0x54d fp=0xc42081b3c0 sp=0xc42081b250 pc=0x4b3672d
main.handleShellMsg(0xc4201e8380, 0xc4201f7140, 0x20, 0xc42092eb70, 0x8, 0xc4201f7160, 0x20, 0xc42092eb80, 0xf, 0xc42092eb78, ...)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:298 +0x2f5 fp=0xc42081b5b0 sp=0xc42081b3c0 pc=0x4b35d95
main.runKernel(0x7ffeefbff9fc, 0x57)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:182 +0xccb fp=0xc42081bf50 sp=0xc42081b5b0 pc=0x4b34d8b
main.main()
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/main.go:26 +0x5d fp=0xc42081bf88 sp=0xc42081bf50 pc=0x4b3771d
runtime.main()
    /Users/brendan/gover/go/src/runtime/proc.go:198 +0x212 fp=0xc42081bfe0 sp=0xc42081bf88 pc=0x4032cf2
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42081bfe8 sp=0xc42081bfe0 pc=0x4060691

goroutine 2 [force gc (idle)]:
runtime.gopark(0x4dda6f8, 0x56ed670, 0x4da7558, 0xf, 0x4dda614, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc420060768 sp=0xc420060748 pc=0x403314a
runtime.goparkunlock(0x56ed670, 0x4da7558, 0xf, 0x14, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:297 +0x5e fp=0xc4200607a8 sp=0xc420060768 pc=0x40331fe
runtime.forcegchelper()
    /Users/brendan/gover/go/src/runtime/proc.go:248 +0xcc fp=0xc4200607e0 sp=0xc4200607a8 pc=0x4032f8c
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200607e8 sp=0xc4200607e0 pc=0x4060691
created by runtime.init.4
    /Users/brendan/gover/go/src/runtime/proc.go:237 +0x35

goroutine 3 [GC sweep wait]:
runtime.gopark(0x4dda6f8, 0x56ed800, 0x4da283d, 0xd, 0x405b714, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc420060f60 sp=0xc420060f40 pc=0x403314a
runtime.goparkunlock(0x56ed800, 0x4da283d, 0xd, 0x14, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:297 +0x5e fp=0xc420060fa0 sp=0xc420060f60 pc=0x40331fe
runtime.bgsweep(0xc420092000)
    /Users/brendan/gover/go/src/runtime/mgcsweep.go:71 +0x12c fp=0xc420060fd8 sp=0xc420060fa0 pc=0x4023aac
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420060fe0 sp=0xc420060fd8 pc=0x4060691
created by runtime.gcenable
    /Users/brendan/gover/go/src/runtime/mgc.go:216 +0x58

goroutine 18 [finalizer wait]:
runtime.gopark(0x4dda6f8, 0x570e0f0, 0x4da5768, 0xe, 0x14, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42005c718 sp=0xc42005c6f8 pc=0x403314a
runtime.goparkunlock(0x570e0f0, 0x4da5768, 0xe, 0x2000000014, 0x1)
    /Users/brendan/gover/go/src/runtime/proc.go:297 +0x5e fp=0xc42005c758 sp=0xc42005c718 pc=0x40331fe
runtime.runfinq()
    /Users/brendan/gover/go/src/runtime/mfinal.go:175 +0xad fp=0xc42005c7e0 sp=0xc42005c758 pc=0x401aa5d
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42005c7e8 sp=0xc42005c7e0 pc=0x4060691
created by runtime.createfing
    /Users/brendan/gover/go/src/runtime/mfinal.go:156 +0x62

goroutine 4 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4200bea80, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42005cf48 sp=0xc42005cf28 pc=0x403314a
runtime.gcBgMarkWorker(0xc420044a00)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42005cfd8 sp=0xc42005cf48 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42005cfe0 sp=0xc42005cfd8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 34 [syscall]:
runtime.notetsleepg(0x570e4e0, 0xffffffffffffffff, 0x2)
    /Users/brendan/gover/go/src/runtime/lock_sema.go:280 +0x4b fp=0xc42005d780 sp=0xc42005d740 pc=0x4014c1b
os/signal.signal_recv(0xc42005d7c8)
    /Users/brendan/gover/go/src/runtime/sigqueue.go:139 +0xa7 fp=0xc42005d7a8 sp=0xc42005d780 pc=0x40483f7
os/signal.loop()
    /Users/brendan/gover/go/src/os/signal/signal_unix.go:22 +0x22 fp=0xc42005d7e0 sp=0xc42005d7a8 pc=0x45bfd42
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42005d7e8 sp=0xc42005d7e0 pc=0x4060691
created by os/signal.init.0
    /Users/brendan/gover/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 35 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc8f0, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42046c748 sp=0xc42046c728 pc=0x403314a
runtime.gcBgMarkWorker(0xc420040000)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42046c7d8 sp=0xc42046c748 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046c7e0 sp=0xc42046c7d8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 36 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4200340b0, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42046cf48 sp=0xc42046cf28 pc=0x403314a
runtime.gcBgMarkWorker(0xc420042500)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42046cfd8 sp=0xc42046cf48 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046cfe0 sp=0xc42046cfd8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 21 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc900, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42005df48 sp=0xc42005df28 pc=0x403314a
runtime.gcBgMarkWorker(0xc420046f00)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42005dfd8 sp=0xc42005df48 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42005dfe0 sp=0xc42005dfd8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 5 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc910, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc420061748 sp=0xc420061728 pc=0x403314a
runtime.gcBgMarkWorker(0xc420049400)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc4200617d8 sp=0xc420061748 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200617e0 sp=0xc4200617d8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 22 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc920, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42005e748 sp=0xc42005e728 pc=0x403314a
runtime.gcBgMarkWorker(0xc42004b900)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42005e7d8 sp=0xc42005e748 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42005e7e0 sp=0xc42005e7d8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 37 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc930, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42046d748 sp=0xc42046d728 pc=0x403314a
runtime.gcBgMarkWorker(0xc42004e000)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42046d7d8 sp=0xc42046d748 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046d7e0 sp=0xc42046d7d8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 38 [GC worker (idle)]:
runtime.gopark(0x4dda598, 0xc4201fc940, 0x4da7ea1, 0x10, 0x14, 0x0)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42046df48 sp=0xc42046df28 pc=0x403314a
runtime.gcBgMarkWorker(0xc420050500)
    /Users/brendan/gover/go/src/runtime/mgc.go:1775 +0x130 fp=0xc42046dfd8 sp=0xc42046df48 pc=0x401e6c0
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046dfe0 sp=0xc42046dfd8 pc=0x4060691
created by runtime.gcBgMarkStartWorkers
    /Users/brendan/gover/go/src/runtime/mgc.go:1723 +0x79

goroutine 6 [syscall]:
runtime.cgocall(0x4b3c7e0, 0xc420071dd0, 0xc420070101)
    /Users/brendan/gover/go/src/runtime/cgocall.go:128 +0x64 fp=0xc420071d80 sp=0xc420071d48 pc=0x4003d74
github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4._C2func_zmq_poll(0xc420076000, 0xc400000001, 0x1f4, 0x0, 0x0, 0x0)
    _cgo_gotypes.go:439 +0x55 fp=0xc420071dd0 sp=0xc420071d80 pc=0x4b21345
github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4.(*Poller).poll.func1(0xc420071f88, 0xc420076000, 0x1, 0x1f4, 0x0, 0x1, 0xc42092e000)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4/polling.go:168 +0xcc fp=0xc420071e18 sp=0xc420071dd0 pc=0x4b2c8cc
github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4.(*Poller).poll(0xc420071f88, 0x1dcd6500, 0xc420071e00, 0x40072fa, 0xc4200aa1e0, 0x0, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4/polling.go:168 +0x151 fp=0xc420071eb8 sp=0xc420071e18 pc=0x4b233b1
github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4.(*Poller).Poll(0xc420071f88, 0x1dcd6500, 0xc4207d6400, 0x0, 0x1, 0x0, 0x0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/vendor/github.com/pebbe/zmq4/polling.go:135 +0x3a fp=0xc420071f08 sp=0xc420071eb8 pc=0x4b2319a
main.startHeartbeat.func1(0xc4200be0d0, 0xc4201e9730, 0xc4200aa1e0)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:548 +0x20a fp=0xc420071fc8 sp=0xc420071f08 pc=0x4b39c3a
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420071fd0 sp=0xc420071fc8 pc=0x4060691
created by main.startHeartbeat
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:535 +0xce

goroutine 44 [IO wait]:
runtime.gopark(0x4dda6c8, 0x6b60578, 0x4d9724e, 0x7, 0x409491b, 0x5)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc4200624d0 sp=0xc4200624b0 pc=0x403314a
runtime.netpollblock(0x6b60550, 0xffffff0000000072, 0x0)
    /Users/brendan/gover/go/src/runtime/netpoll.go:366 +0xaa fp=0xc420062518 sp=0xc4200624d0 pc=0x402d23a
internal/poll.runtime_pollWait(0x6b60550, 0x72, 0xc420062598)
    /Users/brendan/gover/go/src/runtime/netpoll.go:173 +0x57 fp=0xc420062540 sp=0xc420062518 pc=0x402c8b7
internal/poll.(*pollDesc).wait(0xc42015c7e8, 0x72, 0xffffffffffffff01, 0x50b9440, 0x569ff18)
    /Users/brendan/gover/go/src/internal/poll/fd_poll_runtime.go:85 +0x9b fp=0xc420062570 sp=0xc420062540 pc=0x40aa2db
internal/poll.(*pollDesc).waitRead(0xc42015c7e8, 0xc4207ea001, 0x8000, 0x8000)
    /Users/brendan/gover/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d fp=0xc4200625a8 sp=0xc420062570 pc=0x40aa35d
internal/poll.(*FD).Read(0xc42015c7d0, 0xc4207ea000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
    /Users/brendan/gover/go/src/internal/poll/fd_unix.go:157 +0x1dc fp=0xc4200625f8 sp=0xc4200625a8 pc=0x40ab21c
os.(*File).read(0xc4202f22d8, 0xc4207ea000, 0x8000, 0x8000, 0xc4200626c0, 0x50b7501, 0xc4200626a0)
    /Users/brendan/gover/go/src/os/file_unix.go:226 +0x4e fp=0xc420062640 sp=0xc4200625f8 pc=0x40b4f1e
os.(*File).Read(0xc4202f22d8, 0xc4207ea000, 0x8000, 0x8000, 0x8000, 0x8000, 0x18)
    /Users/brendan/gover/go/src/os/file.go:107 +0x6a fp=0xc4200626b0 sp=0xc420062640 pc=0x40b117a
io.copyBuffer(0x50b7980, 0xc4207b57a0, 0x50b7f80, 0xc4202f22d8, 0xc4207ea000, 0x8000, 0x8000, 0x4ca19a0, 0xc420550f01, 0xc4207b57a0)
    /Users/brendan/gover/go/src/io/io.go:400 +0x164 fp=0xc420062720 sp=0xc4200626b0 pc=0x407f5e4
io.Copy(0x50b7980, 0xc4207b57a0, 0x50b7f80, 0xc4202f22d8, 0x0, 0x4039568, 0x4dda5c8)
    /Users/brendan/gover/go/src/io/io.go:362 +0x5a fp=0xc420062780 sp=0xc420062720 pc=0x407f34a
main.handleExecuteRequest.func2(0xc42092ec90, 0xc4201546e0, 0xc4202f22d8)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:380 +0xb4 fp=0xc4200627c8 sp=0xc420062780 pc=0x4b39604
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200627d0 sp=0xc4200627c8 pc=0x4060691
created by main.handleExecuteRequest
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:377 +0x3ff

goroutine 43 [IO wait]:
runtime.gopark(0x4dda6c8, 0x6b60648, 0x4d9724e, 0x7, 0x409491b, 0x5)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x11a fp=0xc42046ecd0 sp=0xc42046ecb0 pc=0x403314a
runtime.netpollblock(0x6b60620, 0xffffff0000000072, 0x0)
    /Users/brendan/gover/go/src/runtime/netpoll.go:366 +0xaa fp=0xc42046ed18 sp=0xc42046ecd0 pc=0x402d23a
internal/poll.runtime_pollWait(0x6b60620, 0x72, 0xc42046ed98)
    /Users/brendan/gover/go/src/runtime/netpoll.go:173 +0x57 fp=0xc42046ed40 sp=0xc42046ed18 pc=0x402c8b7
internal/poll.(*pollDesc).wait(0xc42015c748, 0x72, 0xffffffffffffff01, 0x50b9440, 0x569ff18)
    /Users/brendan/gover/go/src/internal/poll/fd_poll_runtime.go:85 +0x9b fp=0xc42046ed70 sp=0xc42046ed40 pc=0x40aa2db
internal/poll.(*pollDesc).waitRead(0xc42015c748, 0xc4207e2001, 0x8000, 0x8000)
    /Users/brendan/gover/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d fp=0xc42046eda8 sp=0xc42046ed70 pc=0x40aa35d
internal/poll.(*FD).Read(0xc42015c730, 0xc4207e2000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
    /Users/brendan/gover/go/src/internal/poll/fd_unix.go:157 +0x1dc fp=0xc42046edf8 sp=0xc42046eda8 pc=0x40ab21c
os.(*File).read(0xc4202f22c8, 0xc4207e2000, 0x8000, 0x8000, 0xc42046eec0, 0x403325b, 0xc42046eea0)
    /Users/brendan/gover/go/src/os/file_unix.go:226 +0x4e fp=0xc42046ee40 sp=0xc42046edf8 pc=0x40b4f1e
os.(*File).Read(0xc4202f22c8, 0xc4207e2000, 0x8000, 0x8000, 0x8000, 0x8000, 0x18)
    /Users/brendan/gover/go/src/os/file.go:107 +0x6a fp=0xc42046eeb0 sp=0xc42046ee40 pc=0x40b117a
io.copyBuffer(0x50b7980, 0xc420583d80, 0x50b7f80, 0xc4202f22c8, 0xc4207e2000, 0x8000, 0x8000, 0x4ca19a0, 0xc42092e501, 0xc420583d80)
    /Users/brendan/gover/go/src/io/io.go:400 +0x164 fp=0xc42046ef20 sp=0xc42046eeb0 pc=0x407f5e4
io.Copy(0x50b7980, 0xc420583d80, 0x50b7f80, 0xc4202f22c8, 0x0, 0x4039568, 0x4dda5c8)
    /Users/brendan/gover/go/src/io/io.go:362 +0x5a fp=0xc42046ef80 sp=0xc42046ef20 pc=0x407f34a
main.handleExecuteRequest.func1(0xc42092ec90, 0xc4201546e0, 0xc4202f22c8)
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:374 +0xb4 fp=0xc42046efc8 sp=0xc42046ef80 pc=0x4b394f4
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046efd0 sp=0xc42046efc8 pc=0x4060691
created by main.handleExecuteRequest
    /Users/brendan/Documents/mygo/src/github.com/gopherdata/gophernotes/kernel.go:371 +0x3c0

goroutine 12 [chan send]:
runtime.gopark(0xb03c6e8, 0xc4206ae2f8, 0xb028a40, 0x9, 0xc420047d16, 0x3)
    /Users/brendan/gover/go/src/runtime/proc.go:291 +0x126 fp=0xc42046e6a8 sp=0xc42046e688 pc=0xad61986
runtime.goparkunlock(0xc4206ae2f8, 0xb028a40, 0x9, 0x16, 0x3)
    /Users/brendan/gover/go/src/runtime/proc.go:297 +0x5e fp=0xc42046e6e8 sp=0xc42046e6a8 pc=0xad61a3e
runtime.chansend(0xc4206ae2a0, 0xc42046e7c0, 0x42b0a01, 0xaf5d884, 0xc42046e7c0)
    /Users/brendan/gover/go/src/runtime/chan.go:234 +0x26d fp=0xc42046e770 sp=0xc42046e6e8 pc=0xad3af4d
runtime.chansend1(0xc4206ae2a0, 0xc42046e7c0)
    /Users/brendan/gover/go/src/runtime/chan.go:125 +0x35 fp=0xc42046e7a8 sp=0xc42046e770 pc=0xad3acd5
github.com/jung-kurt/gofpdf.glob..func1.1(0xc4206ae2a0)
    /Users/brendan/Documents/mygo/src/github.com/jung-kurt/gofpdf/template.go:91 +0x44 fp=0xc42046e7d8 sp=0xc42046e7a8 pc=0xaf5d884
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42046e7e0 sp=0xc42046e7d8 pc=0xad85111
created by github.com/jung-kurt/gofpdf.glob..func1
    /Users/brendan/Documents/mygo/src/github.com/jung-kurt/gofpdf/template.go:88 +0x58
cosmos72 commented 6 years ago

Hi @btracey, can you please provide the output of go version and go env ?

After replacing your displayPlot with

// Wrap function for plotting as a PNG
func displayPlot(p *plot.Plot) display.Data {
    // This seems to be the best way to plot in jupyter at the moment?
    w, err := p.WriterTo(8*vg.Inch, 8*vg.Inch, "png")
    if err != nil{
        panic(err)
    }
    var b bytes.Buffer
    writer := bufio.NewWriter(&b)
    w.WriteTo(writer)
    return display.PNG(b.Bytes())
}

it worked fine for me (go version go1.10.3 linux/amd64).

The error you reported is very deeply connected with Go runtime, and I am trying to imagine what kind of bug could produce it - my guess is that, unless you hit a compiler bug, only assembler or C code can cause it.

Update: attempting to display the plot as PDF on my system produced a corrupted PDF. So there may be something strange in that part. I will run more tests - in the meantime, it would help if you provide the information I asked above, and also the outcome of re-running your example with my modified displayPlot

btracey commented 6 years ago
brendan:~$ go version
go version go1.10.3 darwin/amd64
brendan:~$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/brendan/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/brendan/Documents/mygo"
GORACE=""
GOROOT="/Users/brendan/gover/go"
GOTMPDIR=""
GOTOOLDIR="/Users/brendan/gover/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l6/mhj4qjrj4437b_lgfz9pm1rw0000gn/T/go-build522914795=/tmp/go-build -gno-record-gcc-switches -fno-common"
cosmos72 commented 6 years ago

Thanks :) So it's Mac OS X.

The plugin module that gophernotes uses to import third party packages is very new on Mac OS X - in go 1.10 and 1.10.1 it was quite bugged. I will do some more tests on it because I am not convinced it is completely stable yet.

btracey commented 6 years ago

It appears to be a problem with multiple cells running at the same time. If I execute each cell individually, the code reliably completes. If I have multiple cells queued at a time (for instance in "restart and run all"), then it reliably panics. (This is with the suggested change)

Here is the updated .ipynb with your changes

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import (\n",
    "    \"bufio\"\n",
    "    \"bytes\"\n",
    "    \n",
    "    \"golang.org/x/exp/rand\"\n",
    "    \n",
    "    \"gonum.org/v1/gonum/stat\"\n",
    "    \"gonum.org/v1/gonum/stat/distmv\"\n",
    "    \"gonum.org/v1/gonum/mat\"\n",
    "    \"gonum.org/v1/plot\"\n",
    "    \"gonum.org/v1/plot/plotter\"\n",
    "    \"gonum.org/v1/plot/vg\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "// First, let's generate fake data. Set dimension and number of fake points\n",
    "nDim := 5\n",
    "nSamples := 2000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "// First, let's generate a random positive definite covariance matrix.\n",
    "dat := make([]float64, nDim*nDim)\n",
    "for i := range dat {\n",
    "    dat[i] = rand.Float64()\n",
    "}\n",
    "a := mat.NewDense(nDim, nDim, dat)\n",
    "sigma := mat.NewSymDense(nDim, nil)\n",
    "sigma.SymOuterK(1,a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Construct the multivariate normal distribution.\n",
    "mu := make([]float64, nDim)\n",
    "for i := range mu{\n",
    "    mu[i] = rand.Float64()\n",
    "}\n",
    "dist, ok := distmv.NewNormal(mu, sigma, nil)\n",
    "if !ok{\n",
    "    panic(\"bad covariance matrix\")\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Sample the distribution to get data\n",
    "samples := mat.NewDense(nSamples, nDim, nil)\n",
    "for i := 0; i < nSamples; i++ {\n",
    "    dist.Rand(samples.RawRowView(i))\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Wrap function for plotting as a pdf\n",
    "func displayPlot(p *plot.Plot) display.Data {\n",
    "    // This seems to be the best way to plot in jupyter at the moment?\n",
    "    w, err := p.WriterTo(8*vg.Inch, 8*vg.Inch, \"png\")\n",
    "    if err != nil{\n",
    "        panic(err)\n",
    "    }\n",
    "    var b bytes.Buffer\n",
    "    writer := bufio.NewWriter(&b)\n",
    "    w.WriteTo(writer)\n",
    "    return display.PNG(b.Bytes())\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Plot the first two dimensions\n",
    "pts := make(plotter.XYs, nSamples)\n",
    "for i := range pts{\n",
    "    pts[i].X = samples.At(i,0)\n",
    "    pts[i].Y = samples.At(i,1)\n",
    "}\n",
    "scat, err := plotter.NewScatter(pts)\n",
    "if err != nil{\n",
    "    panic(err)\n",
    "}\n",
    "p, _ := plot.New()\n",
    "p.Add(scat)\n",
    "data := displayPlot(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Display(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.10.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
btracey commented 6 years ago

Sorry, I don't know if this is a gopherdata issue or something else. I tried to see if this bug was fixed in go1.11beta1 . I'm getting errors the import statement because of the version skew. I tried deleting all of the .so files that get added into $GOPATH/src/gomacro_imports, but they're still happening.

repl.go:5:5: error loading plugin "/Users/brendan/Documents/mygo/src/gomacro_imports/golang.org/x/exp/rand/rand.so": plugin.Open("/Users/brendan/Documents/mygo/src/gomacro_imports/golang.org/x/exp/rand/rand.so"): plugin was built with a different version of package internal/cpu (previous failure)
btracey commented 6 years ago

I also tried deleting all of the data in $GOPATH/pkg and am now getting

repl.go:5:5: error loading package "golang.org/x/exp/rand" metadata, maybe you need to download (go get), compile (go build) and install (go install) it? cannot import, possibly version skew (unknown export format version -1 ("i\x00\xb6\x06\xc6\t?/Users/brendan/Documents/mygo/src/golang.org/x/exp/rand/rand.go\x00\x06Uint64\x04Seed\x04seed\x06Source\x06rng·3\tPCGSource\x03src\areadVal\areadPos>/Users/brendan/Documents/mygo/src/golang.org/x/exp/rand/exp.go")) - reinstall package

I did try re-go-getting, and also installing ,and also installing packages that import golang.org/x/exp/rand. Doesn't seem to work.

cosmos72 commented 6 years ago

Hmm... you can try the following to restore a sane state after upgrading Go:

  1. delete $GOPATH/pkg
  2. execute go clean -cache
  3. reinstall the packages you need with go get, as for example go get golang.org/x/exp/rand and go get gonum.org/v1/plot/...

There is no need to delete the files in $GOPATH/src/gomacro_imports because they are always recreated at each import

btracey commented 6 years ago

I believe the issue was that I also had to recompile gopherdata. (i.e. clean out $GOPATH/bin as well).

I've tried it a couple of times and it seems to be fixed in 1.11beta1. It would be good if someone else could check though.