Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in websocket handling #1116

Closed
na-- opened this issue Aug 16, 2019 · 2 comments · Fixed by #1127
Closed

Panic in websocket handling #1116

na-- opened this issue Aug 16, 2019 · 2 comments · Fixed by #1127
Assignees
Milestone

Comments

@na--
Copy link
Member

na-- commented Aug 16, 2019

We saw this panic in a very complicated websocket script:

*errors.errorString: panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: Panic at 28: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: Panic at 28: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: Panic at 106: Panic at 28: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: Panic at 35: Panic at 106: Panic at 28: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: Panic at 35: Panic at 106: Panic at 28: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xc21917]

goroutine 472 [running]:
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc08e027d68)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0x9b
panic(0xd3ab80, 0xc085e41490)
	/usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc00f314750, 0x0, 0xc08e027c70, 0x0, 0x0, 0x0, 0xc08e027cc8)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x48e
panic(0xd3ab80, 0xc085dd0d40)
	/usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc00f314750, 0x1, 0xc08e027958, 0xa, 0x0, 0x0, 0xc08e0279b0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x48e
panic(0xd3ab80, 0xc085dd0d30)
	/usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc08e026cf8)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0x9b
panic(0xd3ab80, 0xc085dd0d30)
	/usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc00f314750, 0x3, 0xc08e026c00, 0x11, 0x0, 0x0, 0xc08e026c58)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x48e
panic(0xd4f720, 0x19d2580)
	/usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/loadimpact/k6/vendor/github.com/gorilla/websocket.(*Conn).WriteMessage(0x0, 0x1, 0xc0428e4d80, 0xba, 0xc0, 0xc0, 0x18)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/gorilla/websocket/conn.go:732 +0x37
github.com/loadimpact/k6/js/modules/k6/ws.(*Socket).Send(0xc084e49b80, 0xc0428e4cc0, 0xba)
	/home/go/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:349 +0xde
reflect.callMethod(0xc081abde40, 0xc08e026508, 0xc08e0264f0)
	/usr/lib/go/src/reflect/value.go:690 +0x182
reflect.methodValueCall(0xc0428e4cc0, 0xba, 0xc07759a750, 0xc085dd0d20, 0xc08e026748, 0x4bb8e1, 0xc0720b6a50, 0xc081abde40, 0xc07759a750, 0x1000000010, ...)
	/usr/lib/go/src/reflect/asm_amd64.s:35 +0x42
reflect.Value.call(0xcfd6c0, 0xc081abde40, 0x13, 0xe6d4ff, 0x4, 0xc0850b7380, 0x1, 0x1, 0xe65740, 0x1098601, ...)
	/usr/lib/go/src/reflect/value.go:447 +0x461
reflect.Value.Call(0xcfd6c0, 0xc081abde40, 0x13, 0xc0850b7380, 0x1, 0x1, 0xc085dd0d20, 0x98, 0x0)
	/usr/lib/go/src/reflect/value.go:308 +0xa4
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x1098680, 0xc0850b6c40, 0xc08c1e0750, 0x1, 0x19, 0x1098860, 0xc085dd0d10)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1153 +0x791
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc00f314750, 0xc0800a8210, 0x1)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x29a
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x1, 0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4a4
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x51
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc0887926c0, 0x1098cc0, 0x1a08120, 0xc085dd0a20, 0x1, 0x1, 0xc08e026b50, 0xc08befd980)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2c4
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x96
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc00f314750, 0xc08e026c70, 0x0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x10d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x1098cc0, 0x1a08120, 0xc085dd0a20, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x10d
github.com/loadimpact/k6/js/modules/k6/ws.(*WS).Connect(0x1a08450, 0x108b5e0, 0xc088217e30, 0xc00049c300, 0x3c, 0xc085080f40, 0x2, 0x2, 0x0, 0x0, ...)
	/home/go/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:196 +0x7af
reflect.Value.call(0xd3aee0, 0x1a08450, 0x213, 0xe7288b, 0x9, 0xc0878fcc80, 0x3, 0x3, 0xde3e80, 0xc085d92b60, ...)
	/usr/lib/go/src/reflect/value.go:447 +0x461
reflect.Value.CallSlice(0xd3aee0, 0x1a08450, 0x213, 0xc0878fcc80, 0x3, 0x3, 0x194, 0xc08e027628, 0x8b5d26)
	/usr/lib/go/src/reflect/value.go:321 +0xa4
github.com/loadimpact/k6/js/common.Bind.func1(0x1098680, 0xc0104e9200, 0xc08c1e06e0, 0x3, 0x20, 0xc0882498c0, 0xc08e027840)
	/home/go/src/github.com/loadimpact/k6/js/common/bridge.go:239 +0x78a
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc00f314750, 0xc088ae2dc0, 0x3)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x29a
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x3, 0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4a4
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x51
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc00f314750, 0xc08e0279b8, 0x0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x10d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).runTry(0xc00f314750, 0xd35a40)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:375 +0x4e
github.com/loadimpact/k6/vendor/github.com/dop251/goja.try.exec(0x13, 0x0, 0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:2245 +0x51
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc00f314750)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x51
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc0105752c0, 0x1098cc0, 0x1a08120, 0xc085d929a0, 0x1, 0x1, 0xc00fcc5728, 0xc08befd980)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2c4
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x96
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc00f314750, 0xc08e027ce0, 0x0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x10d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x1098cc0, 0x1a08120, 0xc085d929a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
	/home/go/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x10d
github.com/loadimpact/k6/js.(*VU).runFn(0xc01058c2d0, 0x108b520, 0xc0653b7bc0, 0xc0036ae300, 0xc010578a00, 0xc085d929a0, 0x1, 0x1, 0x1098cc0, 0xc08e027f30, ...)
	/home/go/src/github.com/loadimpact/k6/js/runner.go:443 +0x394
github.com/loadimpact/k6/js.(*VU).RunOnce(0xc01058c2d0, 0x108b520, 0xc0653b7bc0, 0x0, 0x0)
	/home/go/src/github.com/loadimpact/k6/js/runner.go:403 +0x1f0
github.com/loadimpact/k6/core/local.(*vuHandle).run(0xc00f530ec0, 0xc00007a240, 0xc0026dc8a0, 0xc00050cba0)
	/home/go/src/github.com/loadimpact/k6/core/local/local.go:70 +0x145

I can't reproduce it with a simple test script, and I can't paste the original script, since it's very complex and has private data in it... 😞 Potentially connected: #581 (comment)

@na-- na-- added bug evaluation needed proposal needs to be validated or tested before fully implementing it in k6 labels Aug 16, 2019
@mstoykov
Copy link
Contributor

This is the case the panic above originated from:

import ws from "k6/ws";

export default function() {

    var response = ws.connect("ws://nonexistant", null, function(socket) {
        socket.on("open", function() {
            socket.send('my-message');
        });
        socket.send('mesage to break ti')
    });
}

@na--
Copy link
Member Author

na-- commented Aug 16, 2019

Ah, and I tried so hard to trigger it with a working websocket connection... 😆 Then this should be easy to fix, and is likely unconnected to the other websocket panic we've seen...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants