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

Hoverfly crash when processing simultaneous requests #767

Closed
john4744 opened this issue Aug 24, 2018 · 2 comments · Fixed by #769
Closed

Hoverfly crash when processing simultaneous requests #767

john4744 opened this issue Aug 24, 2018 · 2 comments · Fixed by #769
Assignees
Labels

Comments

@john4744
Copy link
Contributor

I'm running in simulation mode (though I've hit a similar crash in capture mode too). The simulation is stateful. Here's the error message: fatal error: concurrent map read and map write.
It seems like access to the State map isn't synchronized.

Here is the full dump

fatal error: concurrent map read and map write

goroutine 72 [running]:
runtime.throw(0xac457f, 0x21)
 C:/Go/src/runtime/panic.go:616 +0x88 fp=0xc042faaad8 sp=0xc042faaab8 pc=0x42c6b8
runtime.mapaccess1_faststr(0x9f9ae0, 0xc04274ff80, 0xc0426955b0, 0xb, 0xc042982698)
 C:/Go/src/runtime/hashmap_fast.go:181 +0x428 fp=0xc042faab48 sp=0xc042faaad8 pc=0x40a358
github.com/SpectoLabs/hoverfly/core/matching.StateMatcher(0xc042004e50, 0xc042260450, 0xab123a)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/state_matcher.go:21 +0x160 fp=0xc042faac18 sp=0xc042faab48 pc=0x84ab50
github.com/SpectoLabs/hoverfly/core/matching.MatchingStrategyRunner(0xc04347c174, 0x3d, 0xc04347c150, 0x3, 0xc04347c15b, 0x19, 0xc04347c154, 0x4, 0xc042c3a6f0, 0x0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matching_strategy_runner.go:36 +0x481 fp=0xc042fab100 sp=0xc042faac18 pc=0x84a431
github.com/SpectoLabs/hoverfly/core/matching.Match(0xab2f32, 0x9, 0xc04347c174, 0x3d, 0xc04347c150, 0x3, 0xc04347c15b, 0x19, 0xc04347c154, 0x4, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matcher.go:12 +0x192 fp=0xc042fab1b0 sp=0xc042fab100 pc=0x849f82
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).GetResponse(0xc0421f3900, 0xc04347c174, 0x3d, 0xc04347c150, 0x3, 0xc04347c15b, 0x19, 0xc04347c154, 0x4, 0xc042c3a6f0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly_funcs.go:63 +0x3bc fp=0xc042fab408 sp=0xc042fab1b0 pc=0x94ecec
github.com/SpectoLabs/hoverfly/core/modes.SimulateMode.Process(0xbc25e0, 0xc0421f3900, 0xab2f32, 0x9, 0xc042480800, 0xc04347c174, 0x3d, 0xc04347c150, 0x3, 0xc04347c15b, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/modes/simulate_mode.go:44 +0xc4 fp=0xc042fab7d0 sp=0xc042fab408 pc=0x85e464
github.com/SpectoLabs/hoverfly/core/modes.(*SimulateMode).Process(0xc0420afd40, 0xc042480800, 0xc04347c174, 0x3d, 0xc04347c150, 0x3, 0xc04347c15b, 0x19, 0xc04347c154, 0x4, ...)
 <autogenerated>:1 +0xa8 fp=0xc042fab890 sp=0xc042fab7d0 pc=0x85ff88
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).processRequest(0xc0421f3900, 0xc042480800, 0xf9dfe0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:187 +0x16a fp=0xc042faba38 sp=0xc042fab890 pc=0x94e42a
github.com/SpectoLabs/hoverfly/core.NewProxy.func4(0xc042480800, 0xc0427fe500, 0xc0427fe500, 0x1)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/proxy.go:67 +0x71 fp=0xc042fabac0 sp=0xc042faba38 pc=0x9589c1
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc042fb3d40, 0xc042480800, 0xc0427fe500, 0x1, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41 fp=0xc042fabaf0 sp=0xc042fabac0 pc=0x6eaea1
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ReqProxyConds).Do.func1(0xc042480800, 0xc0427fe500, 0x1406a8, 0x0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/dispatcher.go:200 +0xe8 fp=0xc042fabb50 sp=0xc042fabaf0 pc=0x6f0f88
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc0427e4b60, 0xc042480800, 0xc0427fe500, 0x40dd11, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41 fp=0xc042fabb80 sp=0xc042fabb50 pc=0x6eaea1
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).filterRequest(0xc0421e4000, 0xc042480800, 0xc0427fe500, 0xc042a53d08, 0x4)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:55 +0x99 fp=0xc042fabbd0 sp=0xc042fabb80 pc=0x6eeef9
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).ServeHTTP(0xc0421e4000, 0xbc6520, 0xc04293a0e0, 0xc042480800)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:112 +0x2ae fp=0xc042fabd58 sp=0xc042fabbd0 pc=0x6ef4be
net/http.serverHandler.ServeHTTP(0xc042090750, 0xbc6520, 0xc04293a0e0, 0xc042480800)
 C:/Go/src/net/http/server.go:2694 +0xc3 fp=0xc042fabd88 sp=0xc042fabd58 pc=0x6a3c33
net/http.(*conn).serve(0xc0435fa320, 0xbc6b20, 0xc043393880)
 C:/Go/src/net/http/server.go:1830 +0x658 fp=0xc042fabfc8 sp=0xc042fabd88 pc=0x69ff58
runtime.goexit()
 C:/Go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc042fabfd0 sp=0xc042fabfc8 pc=0x456731
created by net/http.(*Server).Serve
 C:/Go/src/net/http/server.go:2795 +0x282

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x1cb740, 0x72, 0xbc1640)
 C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc04275ef88, 0x72, 0xe9d500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0xf9adf8, 0xc04275edd8, 0xc04242c2a0, 0x1, 0x0, 0x1a0)
 C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).acceptOne(0xc04275edc0, 0x1a0, 0xc042312620, 0x2, 0x2, 0xc04275edd8, 0x4ceba9, 0xc04207a290, 0x41080f, 0x10)
 C:/Go/src/internal/poll/fd_windows.go:793 +0xae
internal/poll.(*FD).Accept(0xc04275edc0, 0xc04207ccd0, 0x0, 0x0, 0x0, 0x0, 0xc000000000, 0x0, 0x0, 0x0, ...)
 C:/Go/src/internal/poll/fd_windows.go:827 +0x142
net.(*netFD).accept(0xc04275edc0, 0xc042a36080, 0xc04207a400, 0x4022f8)
 C:/Go/src/net/fd_windows.go:192 +0x86
net.(*TCPListener).accept(0xc042004ed0, 0xc04207a430, 0x40119e, 0xc042a36080)
 C:/Go/src/net/tcpsock_posix.go:136 +0x35
net.(*TCPListener).AcceptTCP(0xc042004ed0, 0xc04207a478, 0xc04207a480, 0x18)
 C:/Go/src/net/tcpsock.go:246 +0x50
net/http.tcpKeepAliveListener.Accept(0xc042004ed0, 0xb21788, 0xc042a36000, 0xbc6be0, 0xc042dd5020)
 C:/Go/src/net/http/server.go:3216 +0x36
net/http.(*Server).Serve(0xc0420909c0, 0xbc6920, 0xc042004ed0, 0x0, 0x0)
 C:/Go/src/net/http/server.go:2770 +0x1ac
net/http.(*Server).ListenAndServe(0xc0420909c0, 0xc0420909c0, 0xc042c36000)
 C:/Go/src/net/http/server.go:2711 +0xb0
net/http.ListenAndServe(0xc042723f80, 0xe, 0xbbfa40, 0xc042dd4ea0, 0x2, 0xc042723f80)
 C:/Go/src/net/http/server.go:2969 +0x81
github.com/SpectoLabs/hoverfly/core.(*AdminApi).StartAdminInterface(0xc04207a838, 0xc0421f3900)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/admin.go:38 +0x4f2
main.main()
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/cmd/hoverfly/main.go:438 +0x150b

goroutine 38 [IO wait]:
internal/poll.runtime_pollWait(0x1cb810, 0x72, 0xbc1640)
 C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc04275ecc8, 0x72, 0xe9d500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0xf9adf8, 0xc04275eb18, 0xc042af7c40, 0x1, 0x0, 0xf4)
 C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).acceptOne(0xc04275eb00, 0xf4, 0xc0423127e0, 0x2, 0x2, 0xc04275eb18, 0xc0424a3ca8, 0xc0424a3c88, 0x41080f, 0x10)
 C:/Go/src/internal/poll/fd_windows.go:793 +0xae
internal/poll.(*FD).Accept(0xc04275eb00, 0xc043356b40, 0x0, 0x0, 0x0, 0x0, 0xc000000000, 0x0, 0x0, 0x0, ...)
 C:/Go/src/internal/poll/fd_windows.go:827 +0x142
net.(*netFD).accept(0xc04275eb00, 0x0, 0xc0424a3e20, 0x58afb3)
 C:/Go/src/net/fd_windows.go:192 +0x86
net.(*TCPListener).accept(0xc042004e88, 0xf9dfe0, 0x0, 0x0)
 C:/Go/src/net/tcpsock_posix.go:136 +0x35
net.(*TCPListener).Accept(0xc042004e88, 0xbed830e7adecdd08, 0x4b77b15b9, 0xf9dfe0, 0x0)
 C:/Go/src/net/tcpsock.go:259 +0x50
github.com/SpectoLabs/hoverfly/core.(*StoppableListener).Accept(0xc042fb3ef0, 0xb21788, 0xc042a361e0, 0xbc6be0, 0xc042c3a0c0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/listener.go:37 +0x84
net/http.(*Server).Serve(0xc042090750, 0xbc5520, 0xc042fb3ef0, 0x0, 0x0)
 C:/Go/src/net/http/server.go:2770 +0x1ac
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).StartProxy.func1(0xc0421f3900, 0xc042090750, 0xc042fb3ef0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:165 +0xdc
created by github.com/SpectoLabs/hoverfly/core.(*Hoverfly).StartProxy
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:158 +0x4ee

goroutine 28 [runnable]:
github.com/SpectoLabs/hoverfly/core/matching.(*StrongestMatchStrategy).Matching(0xc04225e690, 0xc04335bf90, 0xaaef67, 0x5)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/strongest_match_strategy.go:30 +0x1a1
github.com/SpectoLabs/hoverfly/core/matching.MatchingStrategyRunner(0xc0428e81e4, 0x3d, 0xc0428e81c0, 0x3, 0xc0428e81cb, 0x19, 0xc0428e81c4, 0x4, 0xc0426deba0, 0x0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matching_strategy_runner.go:36 +0x4ba
github.com/SpectoLabs/hoverfly/core/matching.Match(0xab2f32, 0x9, 0xc0428e81e4, 0x3d, 0xc0428e81c0, 0x3, 0xc0428e81cb, 0x19, 0xc0428e81c4, 0x4, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matcher.go:12 +0x192
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).GetResponse(0xc0421f3900, 0xc0428e81e4, 0x3d, 0xc0428e81c0, 0x3, 0xc0428e81cb, 0x19, 0xc0428e81c4, 0x4, 0xc0426deba0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly_funcs.go:63 +0x3bc
github.com/SpectoLabs/hoverfly/core/modes.SimulateMode.Process(0xbc25e0, 0xc0421f3900, 0xab2f32, 0x9, 0xc042480900, 0xc0428e81e4, 0x3d, 0xc0428e81c0, 0x3, 0xc0428e81cb, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/modes/simulate_mode.go:44 +0xc4
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).processRequest(0xc0421f3900, 0xc042480900, 0xf9dfe0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:187 +0x16a
github.com/SpectoLabs/hoverfly/core.NewProxy.func4(0xc042480900, 0xc04225e5f0, 0xc04225e5f0, 0x1)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/proxy.go:67 +0x71
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc042fb3d40, 0xc042480900, 0xc04225e5f0, 0x1, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ReqProxyConds).Do.func1(0xc042480900, 0xc04225e5f0, 0x140d50, 0x0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/dispatcher.go:200 +0xe8
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc0427e4b60, 0xc042480900, 0xc04225e5f0, 0x40dd11, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).filterRequest(0xc0421e4000, 0xc042480900, 0xc04225e5f0, 0xc042a57d08, 0x4)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:55 +0x99
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).ServeHTTP(0xc0421e4000, 0xbc6520, 0xc0421361c0, 0xc042480900)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:112 +0x2ae
net/http.serverHandler.ServeHTTP(0xc042090750, 0xbc6520, 0xc0421361c0, 0xc042480900)
 C:/Go/src/net/http/server.go:2694 +0xc3
net/http.(*conn).serve(0xc042a36140, 0xbc6b20, 0xc043393900)
 C:/Go/src/net/http/server.go:1830 +0x658
created by net/http.(*Server).Serve
 C:/Go/src/net/http/server.go:2795 +0x282

goroutine 29 [runnable]:
github.com/SpectoLabs/hoverfly/core/matching.(*StrongestMatchStrategy).PreMatching(0xc0420bd130)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/strongest_match_strategy.go:24 +0x45
github.com/SpectoLabs/hoverfly/core/matching.MatchingStrategyRunner(0xc042018414, 0x3d, 0xc0420183f0, 0x3, 0xc0420183fb, 0x19, 0xc0420183f4, 0x4, 0xc043488de0, 0x0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matching_strategy_runner.go:18 +0x14b
github.com/SpectoLabs/hoverfly/core/matching.Match(0xab2f32, 0x9, 0xc042018414, 0x3d, 0xc0420183f0, 0x3, 0xc0420183fb, 0x19, 0xc0420183f4, 0x4, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/matching/matcher.go:12 +0x192
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).GetResponse(0xc0421f3900, 0xc042018414, 0x3d, 0xc0420183f0, 0x3, 0xc0420183fb, 0x19, 0xc0420183f4, 0x4, 0xc043488de0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly_funcs.go:63 +0x3bc
github.com/SpectoLabs/hoverfly/core/modes.SimulateMode.Process(0xbc25e0, 0xc0421f3900, 0xab2f32, 0x9, 0xc042480a00, 0xc042018414, 0x3d, 0xc0420183f0, 0x3, 0xc0420183fb, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/modes/simulate_mode.go:44 +0xc4
github.com/SpectoLabs/hoverfly/core.(*Hoverfly).processRequest(0xc0421f3900, 0xc042480a00, 0xf9dfe0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:187 +0x16a
github.com/SpectoLabs/hoverfly/core.NewProxy.func4(0xc042480a00, 0xc0420bd090, 0xc0420bd090, 0x1)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/proxy.go:67 +0x71
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc042fb3d40, 0xc042480a00, 0xc0420bd090, 0x1, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ReqProxyConds).Do.func1(0xc042480a00, 0xc0420bd090, 0x140000, 0x0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/dispatcher.go:200 +0xe8
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc0427e4b60, 0xc042480a00, 0xc0420bd090, 0x40dd11, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).filterRequest(0xc0421e4000, 0xc042480a00, 0xc0420bd090, 0xc042f77d08, 0x4)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:55 +0x99
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).ServeHTTP(0xc0421e4000, 0xbc6520, 0xc04287e1c0, 0xc042480a00)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:112 +0x2ae
net/http.serverHandler.ServeHTTP(0xc042090750, 0xbc6520, 0xc04287e1c0, 0xc042480a00)
 C:/Go/src/net/http/server.go:2694 +0xc3
net/http.(*conn).serve(0xc042a361e0, 0xbc6b20, 0xc043393a00)
 C:/Go/src/net/http/server.go:1830 +0x658
created by net/http.(*Server).Serve
 C:/Go/src/net/http/server.go:2795 +0x282

goroutine 71 [runnable]:
bytes.makeSlice(0x200, 0x1536f0, 0x0, 0xc0421aa030)
 C:/Go/src/bytes/buffer.go:223 +0xb7
bytes.(*Buffer).grow(0xc042d26230, 0x200, 0xc0435074a0)
 C:/Go/src/bytes/buffer.go:144 +0x158
bytes.(*Buffer).Grow(0xc042d26230, 0x200)
 C:/Go/src/bytes/buffer.go:163 +0x41
io/ioutil.readAll(0x1cb940, 0xc04335cbe0, 0x200, 0x0, 0x0, 0x0, 0x0, 0x0)
 C:/Go/src/io/ioutil/ioutil.go:34 +0x9a
io/ioutil.ReadAll(0x1cb940, 0xc04335cbe0, 0xc04335cbe0, 0x1cb940, 0xc04335cbe0, 0x0, 0x0)
 C:/Go/src/io/ioutil/ioutil.go:45 +0x45
github.com/SpectoLabs/hoverfly/core/util.GetRequestBody(0xc042480700, 0xc0420a7dd0, 0x0, 0xc0421aa030, 0x0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/util/util.go:24 +0x67
github.com/SpectoLabs/hoverfly/core/models.NewRequestDetailsFromHttpRequest(0xc042480700, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/models/payload.go:73 +0x79
github.com/SpectoLabs/hoverfly/core/journal.(*Journal).NewEntry(0xc0420afd20, 0xc042480700, 0xc0434122d0, 0xab227d, 0x8, 0xbed830e76decdd08, 0x47be04bb9, 0xf9dfe0, 0x19, 0x1)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/journal/journal.go:44 +0x9e
github.com/SpectoLabs/hoverfly/core.NewProxy.func4(0xc042480700, 0xc0433be500, 0xc0433be500, 0x1)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/core/proxy.go:68 +0xd1
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc042fb3d40, 0xc042480700, 0xc0433be500, 0x1, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ReqProxyConds).Do.func1(0xc042480700, 0xc0433be500, 0x1536f0, 0x0)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/dispatcher.go:200 +0xe8
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.FuncReqHandler.Handle(0xc0427e4b60, 0xc042480700, 0xc0433be500, 0x40dd11, 0x10)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/actions.go:19 +0x41
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).filterRequest(0xc0421e4000, 0xc042480700, 0xc0433be500, 0xc042a55d08, 0x4)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:55 +0x99
github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy.(*ProxyHttpServer).ServeHTTP(0xc0421e4000, 0xbc6520, 0xc0434741c0, 0xc042480700)
 C:/Users/john4744/go/src/github.com/SpectoLabs/hoverfly/vendor/github.com/SpectoLabs/goproxy/proxy.go:112 +0x2ae
net/http.serverHandler.ServeHTTP(0xc042090750, 0xbc6520, 0xc0434741c0, 0xc042480700)
 C:/Go/src/net/http/server.go:2694 +0xc3
net/http.(*conn).serve(0xc0435fa280, 0xbc6b20, 0xc043393800)
 C:/Go/src/net/http/server.go:1830 +0x658
created by net/http.(*Server).Serve
 C:/Go/src/net/http/server.go:2795 +0x282

goroutine 73 [IO wait]:
internal/poll.runtime_pollWait(0x1cb5a0, 0x72, 0xbc1640)
 C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc0428a7a88, 0x72, 0xe9d500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0xf9adf8, 0xc0428a78d8, 0xb21558, 0x516f3333386e6261, 0x524e30626137576b, 0x5073423255517864)
 C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).Read(0xc0428a78c0, 0xc043488a91, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_windows.go:484 +0x248
net.(*netFD).Read(0xc0428a78c0, 0xc043488a91, 0x1, 0x1, 0x70583774526d5654, 0x376c463337675141, 0x32434f4b41655446)
 C:/Go/src/net/fd_windows.go:151 +0x56
net.(*conn).Read(0xc0428aa040, 0xc043488a91, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/net/net.go:176 +0x71
net/http.(*connReader).backgroundRead(0xc043488a80)
 C:/Go/src/net/http/server.go:668 +0x61
created by net/http.(*connReader).startBackgroundRead
 C:/Go/src/net/http/server.go:664 +0xd5

goroutine 43 [runnable]:
net/http.(*connReader).backgroundRead(0xc043488cc0)
 C:/Go/src/net/http/server.go:667
created by net/http.(*connReader).startBackgroundRead
 C:/Go/src/net/http/server.go:664 +0xd5

goroutine 53 [IO wait]:
internal/poll.runtime_pollWait(0x1cb670, 0x72, 0xbc1640)
 C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc0428a7d48, 0x72, 0xe9d500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0xf9adf8, 0xc0428a7b98, 0xb21558, 0xc042480500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).Read(0xc0428a7b80, 0xc043488b51, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_windows.go:484 +0x248
net.(*netFD).Read(0xc0428a7b80, 0xc043488b51, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/net/fd_windows.go:151 +0x56
net.(*conn).Read(0xc0428aa048, 0xc043488b51, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/net/net.go:176 +0x71
net/http.(*connReader).backgroundRead(0xc043488b40)
 C:/Go/src/net/http/server.go:668 +0x61
created by net/http.(*connReader).startBackgroundRead
 C:/Go/src/net/http/server.go:664 +0xd5

goroutine 30 [IO wait]:
internal/poll.runtime_pollWait(0x1cb4d0, 0x72, 0xbc1640)
 C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc0434a3248, 0x72, 0xe9d500, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0xf9adf8, 0xc0434a3098, 0xb21558, 0x0, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).Read(0xc0434a3080, 0xc043488c11, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/internal/poll/fd_windows.go:484 +0x248
net.(*netFD).Read(0xc0434a3080, 0xc043488c11, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/net/fd_windows.go:151 +0x56
net.(*conn).Read(0xc0423d4958, 0xc043488c11, 0x1, 0x1, 0x0, 0x0, 0x0)
 C:/Go/src/net/net.go:176 +0x71
net/http.(*connReader).backgroundRead(0xc043488c00)
 C:/Go/src/net/http/server.go:668 +0x61
created by net/http.(*connReader).startBackgroundRead
 C:/Go/src/net/http/server.go:664 +0xd5

@john4744
Copy link
Contributor Author

Not sure if this is a good idea or not... but I just added some basic locking using a RWMutex on State. This seemed to resolve the crashes I was seeing (in simulation and capture). Here's a diff master...john4744:sync-state
If this sounds like the right approach, I'll submit a PR.

@benjih
Copy link
Contributor

benjih commented Sep 5, 2018

Hey @john4744,

What you have said makes complete sense and I think the approach you have taken looks right. My only niggle with it is in core/matching/strongest_match_strategy.go you create a copy of the state while locking and unlocking it, but you do not do the same in core/matching/state_matcher.go. If you could update the state_matcher.go file to use a copy of the state, I think this would be just that little bit better.

Would definitely love a PR though, as it looks great and looks like something we should definitely solve.

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

Successfully merging a pull request may close this issue.

3 participants