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

fix: don't use defer in a loop #445

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

lbcjbb
Copy link
Contributor

@lbcjbb lbcjbb commented Jul 12, 2024

These changes fixes a crash in tests when using WithCompleteRequest() or WithCompleteResponse()` with multiple headers.

unexpected fault address 0x1d4c860
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0x1d4c860 pc=0x4a28fd]

goroutine 14 gp=0xc0003c28c0 m=3 mp=0xc00009d008 [running]:
runtime.throw({0x1e99d7e?, 0xc000111f80?})
	GOROOT/src/runtime/panic.go:1023 +0x5c fp=0xc0000eb660 sp=0xc0000eb630 pc=0x46cd7c
runtime.sigpanic()
	GOROOT/src/runtime/signal_unix.go:895 +0x285 fp=0xc0000eb6c0 sp=0xc0000eb660 pc=0x487265
runtime/internal/atomic.casPointer(0x1d4c860?, 0x46c765?, 0x46b700?)
	GOROOT/src/runtime/atomic_pointer.go:63 +0x3d fp=0xc0000eb6e0 sp=0xc0000eb6c0 pc=0x4a28fd
runtime/internal/atomic.(*UnsafePointer).CompareAndSwap(...)
	GOROOT/src/runtime/internal/atomic/types.go:512
runtime/internal/atomic.(*Pointer[...]).CompareAndSwap(...)
	GOROOT/src/runtime/internal/atomic/types.go:570
runtime.deferconvert(0xc0000edc88)
	GOROOT/src/runtime/panic.go:436 +0x77 fp=0xc0000eb720 sp=0xc0000eb6e0 pc=0x46b777
runtime.(*_panic).nextDefer(0xc0000eb768)
	GOROOT/src/runtime/panic.go:879 +0x125 fp=0xc0000eb750 sp=0xc0000eb720 pc=0x46c765
runtime.deferreturn()
	GOROOT/src/runtime/panic.go:598 +0x68 fp=0xc0000eb7e0 sp=0xc0000eb750 pc=0x46be08
github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).withHeaders(0xc00043034c, 0x0, 0xc0000ebc60)
	github.com/pact-foundation/pact-go/v2/internal/native/mock_server.go:709 +0x1ec fp=0xc0000eb8d0 sp=0xc0000eb7e0 pc=0xf6d60c
github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).WithRequestHeaders(...)
	github.com/pact-foundation/pact-go/v2/internal/native/mock_server.go:686
github.com/pact-foundation/pact-go/v2/consumer.(*Interaction).WithCompleteRequest(0xc00011e198, {{0x1e98bce, 0x3}, {0x20178c8, 0x2010de0}, 0x0, 0xc0004441e0, {0x0, 0x0}})
	github.com/pact-foundation/pact-go/v2/consumer/interaction.go:31 +0x3ec fp=0xc0000ebd00 sp=0xc0000eb8d0 pc=0xf7678c
github.com/pact-foundation/pact-go/v2/consumer.(*V4UnconfiguredInteraction).WithCompleteRequest(...)
	github.com/pact-foundation/pact-go/v2/consumer/http_v4.go:97

@lbcjbb lbcjbb changed the title fix: don't use defer in loop fix: don't use defer in a loop Jul 12, 2024
@coveralls
Copy link

Coverage Status

coverage: 29.383% (+0.03%) from 29.358%
when pulling ac7f9cf on lbcjbb:fix-crash
into a396cac on pact-foundation:master.

@mefellows mefellows merged commit 4d46c69 into pact-foundation:master Jul 15, 2024
17 checks passed
@mefellows
Copy link
Member

Thanks for this, i'll get a new release out shortly.

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

Successfully merging this pull request may close these issues.

3 participants