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

Runtime error occurs with golang 1.22.x #402

Closed
m15o opened this issue Apr 12, 2024 · 8 comments · Fixed by #422
Closed

Runtime error occurs with golang 1.22.x #402

m15o opened this issue Apr 12, 2024 · 8 comments · Fixed by #422
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@m15o
Copy link
Contributor

m15o commented Apr 12, 2024

Software versions

  • OS: golang:1.22.2-bullseye (docker image), ubuntu 22.04
  • Consumer Pact library: pact-go v2.0.4
  • Golang Version: go version go1.22.2 linux/amd64, go version go1.22.1 linux/amd64, go version go1.22.0 linux/amd64
  • Golang environment: Provide output of go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/work/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3016183765=/tmp/go-build -gno-record-gcc-switches'

Expected behaviour

pact-go consumer test should run successfully without error

Actual behaviour

The test fails with the following error

unexpected return pc for github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).GivenWithParameter called from 0xe18a8f```

Steps to reproduce

The code is pretty match same as the example test on github.
https://github.com/pact-foundation/pact-go/blob/master/examples/consumer_v4_test.go

  1. save the following go code in a file named `consumer_v4_test.go
  2. run go test -v -race ./...
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"strings"
	"testing"

	"github.com/pact-foundation/pact-go/v2/consumer"
	"github.com/pact-foundation/pact-go/v2/log"
	"github.com/pact-foundation/pact-go/v2/matchers"
	"github.com/pact-foundation/pact-go/v2/models"
	"github.com/stretchr/testify/assert"
)

type S = matchers.S

var Like = matchers.Like
var Regex = matchers.Regex
var ArrayMinLike = matchers.ArrayMinLike

type Map = matchers.MapMatcher

var Decimal = matchers.Decimal
var Integer = matchers.Integer
var Equality = matchers.Equality
var Includes = matchers.Includes
var FromProviderState = matchers.FromProviderState
var ArrayContaining = matchers.ArrayContaining
var ArrayMinMaxLike = matchers.ArrayMinMaxLike
var DateTimeGenerated = matchers.DateTimeGenerated

func TestConsumerV4(t *testing.T) {
	log.SetLogLevel("TRACE")

	mockProvider, err := consumer.NewV4Pact(consumer.MockHTTPProviderConfig{
		Consumer: "PactGoV4Consumer",
		Provider: "V4Provider",
		Host:     "127.0.0.1",
		TLS:      true,
	})
	assert.NoError(t, err)

	// Set up our expected interactions.
	err = mockProvider.
		AddInteraction().
		Given("state 1").
		GivenWithParameter(models.ProviderState{
			Name: "User foo exists",
			Parameters: map[string]interface{}{
				"id": "foo",
			},
		}).
		UponReceiving("A request to do a foo").
		WithRequest("POST", "/foobar", func(b *consumer.V4RequestBuilder) {
			b.
				Header("Content-Type", S("application/json")).
				Header("Authorization", Like("Bearer 1234")).
				Query("baz", Regex("bar", "[a-z]+"), Regex("bat", "[a-z]+"), Regex("baz", "[a-z]+")).
				JSONBody(Map{
					"id":       Like(27),
					"name":     FromProviderState("${name}", "billy"),
					"lastName": Like("billy"),
					"datetime": DateTimeGenerated("2020-01-01T08:00:45", "yyyy-MM-dd'T'HH:mm:ss"),
				})

		}).
		WillRespondWith(200, func(b *consumer.V4ResponseBuilder) {
			b.
				Header("Content-Type", S("application/json")).
				JSONBody(Map{
					"datetime":       Regex("2020-01-01", "[0-9\\-]+"),
					"name":           S("Billy"),
					"lastName":       S("Sampson"),
					"superstring":    Includes("foo"),
					"id":             Integer(12),
					"accountBalance": Decimal(123.76),
					"itemsMinMax":    ArrayMinMaxLike(27, 3, 5),
					"itemsMin":       ArrayMinLike("thereshouldbe3ofthese", 3),
					"equality":       Equality("a thing"),
					"arrayContaining": ArrayContaining([]interface{}{
						Like("string"),
						Integer(1),
						Map{
							"foo": Like("bar"),
						},
					}),
				})
		}).
		ExecuteTest(t, test)
	assert.NoError(t, err)
}

var test = func() func(config consumer.MockServerConfig) error {
	return rawTest("baz=bat&baz=foo&baz=something")
}()

var rawTest = func(query string) func(config consumer.MockServerConfig) error {

	return func(config consumer.MockServerConfig) error {

		config.TLSConfig.InsecureSkipVerify = true
		client := &http.Client{
			Transport: &http.Transport{
				TLSClientConfig: config.TLSConfig,
			},
		}
		req := &http.Request{
			Method: "POST",
			URL: &url.URL{
				Host:     fmt.Sprintf("%s:%d", "localhost", config.Port),
				Scheme:   "https",
				Path:     "/foobar",
				RawQuery: query,
			},
			Body:   io.NopCloser(strings.NewReader(`{"id": 27, "name":"billy", "lastName":"sampson", "datetime":"2021-01-01T08:00:45"}`)),
			Header: make(http.Header),
		}

		// NOTE: by default, request bodies are expected to be sent with a Content-Type
		// of application/json. If you don't explicitly set the content-type, you
		// will get a mismatch during Verification.
		req.Header.Set("Content-Type", "application/json")
		req.Header.Set("Authorization", "Bearer 1234")

		_, err := client.Do(req)

		return err
	}
}

Relevent log files

=== RUN   TestConsumerV4
2024/04/11 23:50:54 [DEBUG] pact setup
2024/04/11 23:50:54 [DEBUG] initialising native interface
2024/04/11 23:50:54 [DEBUG] initialised native log level to TRACE (5)
2024/04/11 23:50:54 [DEBUG] initialised native log to log to stdout
2024/04/11 23:50:54 [DEBUG] log_to_stdout res 0
2024/04/11 23:50:54 [DEBUG] pact add V4 interaction
2024-04-11T23:50:54.151457Z TRACE ThreadId(01) pact_ffi::mock_server::handles: with_pact - ref = 1, keys = [1]
2024-04-11T23:50:54.152984Z TRACE ThreadId(01) pact_ffi::mock_server::handles: with_pact before - ref = 1, inner = RefCell { value: PactHandleInner { pact: V4Pact { consumer: Consumer { name: "PactGoV4Consumer" }, provider: Provider { name: "V4Provider" }, interactions: [], metadata: {"pactRust": Object {"ffi": String("0.4.16")}}, plugin_data: [] }, mock_server_started: false, specification_version: V4 } }
2024-04-11T23:50:54.154728Z TRACE ThreadId(01) pact_ffi::mock_server::handles: with_pact after - ref = 1, inner = RefCell { value: PactHandleInner { pact: V4Pact { consumer: Consumer { name: "PactGoV4Consumer" }, provider: Provider { name: "V4Provider" }, interactions: [SynchronousHttp { id: None, key: None, description: "", provider_states: [], request: HttpRequest { method: "GET", path: "/", query: None, headers: None, body: Missing, matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }, response: HttpResponse { status: 200, headers: None, body: Missing, matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }, comments: {}, pending: false, plugin_config: {}, interaction_markup: InteractionMarkup { markup: "", markup_type: "" }, transport: None }], metadata: {"pactRust": Object {"ffi": String("0.4.16")}}, plugin_data: [] }, mock_server_started: false, specification_version: V4 } }
2024-04-11T23:50:54.155327Z TRACE ThreadId(02) pact_ffi::mock_server::handles: with_interaction - index = 1, interaction = 1
2024-04-11T23:50:54.155334Z TRACE ThreadId(02) pact_ffi::mock_server::handles: with_interaction - keys = [1]
2024-04-11T23:50:54.155336Z TRACE ThreadId(02) pact_ffi::mock_server::handles: with_interaction - inner = PactHandleInner { pact: V4Pact { consumer: Consumer { name: "PactGoV4Consumer" }, provider: Provider { name: "V4Provider" }, interactions: [SynchronousHttp { id: None, key: None, description: "", provider_states: [], request: HttpRequest { method: "GET", path: "/", query: None, headers: None, body: Missing, matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }, response: HttpResponse { status: 200, headers: None, body: Missing, matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }, comments: {}, pending: false, plugin_config: {}, interaction_markup: InteractionMarkup { markup: "", markup_type: "" }, transport: None }], metadata: {"pactRust": Object {"ffi": String("0.4.16")}}, plugin_data: [] }, mock_server_started: false, specification_version: V4 }
2024-04-11T23:50:54.155824Z TRACE ThreadId(02) pact_ffi::mock_server::handles: with_interaction - index = 195, interaction = 37920
2024-04-11T23:50:54.155827Z TRACE ThreadId(02) pact_ffi::mock_server::handles: with_interaction - keys = [1]
runtime: g 19: unexpected return pc for github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).GivenWithParameter called from 0xe18a8f
stack: frame={sp:0xc0000b1bf8, fp:0xc0000b1d28} stack=[0xc0000b0000,0xc0000b2000)
0x000000c0000b1af8:  0x0000000002320000  0x000000c0000b1ac8
0x000000c0000b1b08:  0x0000000000c38fcc <github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).GivenWithParameter+0x00000000000000cc>  0x0000000000000000
0x000000c0000b1b18:  0x0000000000000000  0x0000000000000000
0x000000c0000b1b28:  0x000000c00002c060  0x0000000000f32950
0x000000c0000b1b38:  0x0000000000e18a8f  0x00007fffac000d80
0x000000c0000b1b48:  0x0000000002324ec0  0x0000000002324c00
0x000000c0000b1b58:  0x000000c00002c070  0x000000c00002c060
0x000000c0000b1b68:  0x000000c0000b1da0  0x0000000000000000
0x000000c0000b1b78:  0x0000000000c39500 <github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).GivenWithParameter.deferwrap1+0x0000000000000000>  0x0000000002324ec0
0x000000c0000b1b88:  0x0000000000000000  0x0000000000000000
0x000000c0000b1b98:  0x0000000000d5d880  0x000000c0000b1e28
0x000000c0000b1ba8:  0x000000c0000b1d18  0x000000c0000b1d18
0x000000c0000b1bb8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1bc8:  0x0000000000000000  0x0000000004000105
0x000000c0000b1bd8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1be8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1bf8: <0x0000000000000000  0x0000000000000000
0x000000c0000b1c08:  0x0000000000000000  0x000000c0000b1e28
0x000000c0000b1c18:  0x000000000000000f  0x000000c0000b1e28
0x000000c0000b1c28:  0x000000c000012018  0x0000000000e2171c
0x000000c0000b1c38:  0x000000c0000b1ed8  0x0000000000cac4ba <pact-go-test.TestConsumerV4+0x000000000000023a>
0x000000c0000b1c48:  0x000000c00002c050  0x0000000000e2171c
0x000000c0000b1c58:  0x0000000000e18a8f  0x000000c0000b1e28
0x000000c0000b1c68:  0x0000000000000000  0x0000000000000000
0x000000c0000b1c78:  0x0000000000000000  0x0000000000000000
0x000000c0000b1c88:  0x0000000000e1d539  0x0000000000000009
0x000000c0000b1c98:  0x0000000000000000  0x0000000000000000
0x000000c0000b1ca8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1cb8:  0x0000000000000001  0xfb99622a00000000
0x000000c0000b1cc8:  0x00000000012333c0  0x000000c000092318
0x000000c0000b1cd8:  0x00000000000000e0  0x0000000000000603
0x000000c0000b1ce8:  0x00000000012333c0  0x000000c00002c050
0x000000c0000b1cf8:  0x00000000012333c0  0x000000c0000b1da0
0x000000c0000b1d08:  0x000000c000012018  0x0000000000000000
0x000000c0000b1d18:  0x00000000000000b0  0x0000000000e18a8f
0x000000c0000b1d28: >0x0000000000000002  0x0000000000000000
0x000000c0000b1d38:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d48:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d58:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d68:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d78:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d88:  0x0000000000000000  0x0000000000000000
0x000000c0000b1d98:  0x0000000000000000  0x0000000000d2fd40
0x000000c0000b1da8:  0x0000000000f32950  0x0000000000000000
0x000000c0000b1db8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1dc8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1dd8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1de8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1df8:  0x0000000000000000  0x0000000000000000
0x000000c0000b1e08:  0x0000000000000000  0x0000000000000000
0x000000c0000b1e18:  0x0000000000000000  0x0000000000000000
fatal error: unknown caller pc

runtime stack:
runtime.throw({0xe22fa7?, 0x1309670?})
/usr/local/go/src/runtime/panic.go:1023 +0x5c fp=0x7fffb4dfc900 sp=0x7fffb4dfc8d0 pc=0x4423fc
runtime.(*unwinder).next(0x7fffb4dfc9a8)
/usr/local/go/src/runtime/traceback.go:469 +0x24c fp=0x7fffb4dfc978 sp=0x7fffb4dfc900 pc=0x46f7ac
runtime.(*_panic).nextFrame.func1()
/usr/local/go/src/runtime/panic.go:938 +0xa6 fp=0x7fffb4dfca30 sp=0x7fffb4dfc978 pc=0x442026
runtime.systemstack(0x800000)
/usr/local/go/src/runtime/asm_amd64.s:509 +0x4a fp=0x7fffb4dfca40 sp=0x7fffb4dfca30 pc=0x47d1aa

goroutine 19 gp=0xc000186000 m=4 mp=0xc00004f808 [running]:
runtime.systemstack_switch()
/usr/local/go/src/runtime/asm_amd64.s:474 +0x8 fp=0xc0000b1848 sp=0xc0000b1838 pc=0x47d148
runtime.(*_panic).nextFrame(0xc0000b18a8?)
/usr/local/go/src/runtime/panic.go:911 +0x65 fp=0xc0000b1888 sp=0xc0000b1848 pc=0x441f45
runtime.(*_panic).nextDefer(0xc0000b18e0)
/usr/local/go/src/runtime/panic.go:898 +0xa9 fp=0xc0000b18b8 sp=0xc0000b1888 pc=0x441d69
panic({0xd658e0?, 0x1320330?})
/usr/local/go/src/runtime/panic.go:766 +0x13c fp=0xc0000b1968 sp=0xc0000b18b8 pc=0x44191c
runtime.panicmem(...)
/usr/local/go/src/runtime/panic.go:261
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:881 +0x378 fp=0xc0000b19c8 sp=0xc0000b1968 pc=0x45c958
runtime/internal/atomic.(*Pointer[...]).Load(...)
/usr/local/go/src/runtime/internal/atomic/types.go:526
runtime.deferconvert(0xc0000b1be0)
/usr/local/go/src/runtime/panic.go:435 +0x64 fp=0xc0000b1a08 sp=0xc0000b19c8 pc=0x440de4
runtime.(*_panic).nextDefer(0xc0000b1a50)
/usr/local/go/src/runtime/panic.go:879 +0x125 fp=0xc0000b1a38 sp=0xc0000b1a08 pc=0x441de5
runtime.deferreturn()
/usr/local/go/src/runtime/panic.go:598 +0x68 fp=0xc0000b1ac8 sp=0xc0000b1a38 pc=0x441488
github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).GivenWithParameter(0x0, {0x0, 0x0}, 0xc0000b1e28)
/go/pkg/mod/github.com/pact-foundation/pact-go/[email protected]/internal/native/mock_server.go:669 +0x3d1 fp=0xc0000b1bf8 sp=0xc0000b1ac8 pc=0xc392d1
created by testing.(*T).Run in goroutine 1
/usr/local/go/src/testing/testing.go:1742 +0x826

goroutine 1 gp=0xc0000061c0 m=nil [chan receive]:
runtime.gopark(0x18?, 0x1382f60?, 0x18?, 0x0?, 0x7ffffd14b548?)
/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000161710 sp=0xc0001616f0 pc=0x4453ce
runtime.chanrecv(0xc000144690, 0xc0001617f7, 0x1)
/usr/local/go/src/runtime/chan.go:583 +0x36d fp=0xc000161788 sp=0xc000161710 pc=0x40e7ad
runtime.chanrecv1(0x1382f60?, 0xd2fd40?)
/usr/local/go/src/runtime/chan.go:442 +0x12 fp=0xc0001617b0 sp=0xc000161788 pc=0x40e412
testing.(*T).Run(0xc0000ced00, {0xe20c5a, 0xe}, 0xe611e0)
/usr/local/go/src/testing/testing.go:1750 +0x851 fp=0xc0001618d0 sp=0xc0001617b0 pc=0x5b64b1
testing.runTests.func1(0xc0000ced00)
/usr/local/go/src/testing/testing.go:2161 +0x86 fp=0xc000161920 sp=0xc0001618d0 pc=0x5ba646
testing.tRunner(0xc0000ced00, 0xc000161b10)
/usr/local/go/src/testing/testing.go:1689 +0x21f fp=0xc0001619e8 sp=0xc000161920 pc=0x5b49ff
testing.runTests(0xc000094720, {0x1321d90, 0x1, 0x1}, {0x416f3c?, 0xd0?, 0x1383a80?})
/usr/local/go/src/testing/testing.go:2159 +0x8bf fp=0xc000161b40 sp=0xc0001619e8 pc=0x5ba49f
testing.(*M).Run(0xc00017c500)
/usr/local/go/src/testing/testing.go:2027 +0xf18 fp=0xc000161ec8 sp=0xc000161b40 pc=0x5b7a78
main.main()
_testmain.go:47 +0x2be fp=0xc000161f50 sp=0xc000161ec8 pc=0xcad8be
runtime.main()
/usr/local/go/src/runtime/proc.go:271 +0x29d fp=0xc000161fe0 sp=0xc000161f50 pc=0x444f5d
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000161fe8 sp=0xc000161fe0 pc=0x47f161

goroutine 2 gp=0xc000006c40 m=nil [force gc (idle)]:
runtime.gopark(0x1340df0?, 0x1384a00?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc0000487a8 sp=0xc000048788 pc=0x4453ce
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:326 +0xb3 fp=0xc0000487e0 sp=0xc0000487a8 pc=0x445233
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0000487e8 sp=0xc0000487e0 pc=0x47f161
created by runtime.init.6 in goroutine 1
/usr/local/go/src/runtime/proc.go:314 +0x1a

goroutine 3 gp=0xc000007180 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000058f80 sp=0xc000058f60 pc=0x4453ce
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.bgsweep(0xc00002a070)
/usr/local/go/src/runtime/mgcsweep.go:278 +0x94 fp=0xc000058fc8 sp=0xc000058f80 pc=0x42ed14
runtime.gcenable.gowrap1()
/usr/local/go/src/runtime/mgc.go:203 +0x25 fp=0xc000058fe0 sp=0xc000058fc8 pc=0x423685
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x47f161
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:203 +0x66

goroutine 4 gp=0xc000007340 m=nil [GC scavenge wait]:
runtime.gopark(0xc00002a070?, 0xf2fc90?, 0x1?, 0x0?, 0xc000007340?)
/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc00005ef78 sp=0xc00005ef58 pc=0x4453ce
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.(*scavengerState).park(0x1383c20)
/usr/local/go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc00005efa8 sp=0xc00005ef78 pc=0x42c729
runtime.bgscavenge(0xc00002a070)
/usr/local/go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc00005efc8 sp=0xc00005efa8 pc=0x42cc9c
runtime.gcenable.gowrap2()
/usr/local/go/src/runtime/mgc.go:204 +0x25 fp=0xc00005efe0 sp=0xc00005efc8 pc=0x423625
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00005efe8 sp=0xc00005efe0 pc=0x47f161
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:204 +0xa5

goroutine 18 gp=0xc000084380 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc00005fe20 sp=0xc00005fe00 pc=0x4453ce
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:194 +0x145 fp=0xc00005ffe0 sp=0xc00005fe20 pc=0x4226c5
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00005ffe8 sp=0xc00005ffe0 pc=0x47f161
created by runtime.createfing in goroutine 1
/usr/local/go/src/runtime/mfinal.go:164 +0x3d
FAIL    pact-go-test    0.094s
FAIL

Additional information

@mefellows mefellows added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Apr 12, 2024
@mefellows
Copy link
Member

Thanks, it's hard to know if the issue is with Go or something else at this stage. Appreciate the repro.

@YOU54F
Copy link
Member

YOU54F commented Apr 12, 2024

There definitely seems to be an issue in linux builds reported over in golang, and is affecting our ci runs with all published version of golang 1.22.x (0,1,2)

I've not tested linux aarch64 yet.

Definitely appreciate the repro

I've been using

docker run --platform linux/amd64 --rm -it -v $PWD:/app golang:latest
cd /app
apt-get update
apt-get install -y openjdk-17-jdk
make test

which gives me the same error on the first test

--- FAIL: TestHttpV4TypeSystem (0.04s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x441144]

goroutine 19 [running]:
testing.tRunner.func1.2({0xc5c1c0, 0x1183260})
        /usr/local/go/src/testing/testing.go:1631 +0x3f7
testing.tRunner.func1()
        /usr/local/go/src/testing/testing.go:1634 +0x6b6
panic({0xc5c1c0?, 0x1183260?})
        /usr/local/go/src/runtime/panic.go:770 +0x132
runtime/internal/atomic.(*Pointer[...]).Load(...)
        /usr/local/go/src/runtime/internal/atomic/types.go:526
github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).withHeaders(0xc0001aa34c, 0x0, 0xc0001b9b98)
        /app/internal/native/mock_server.go:709 +0x1ec
github.com/pact-foundation/pact-go/v2/internal/native.(*Interaction).WithRequestHeaders(...)
        /app/internal/native/mock_server.go:686
github.com/pact-foundation/pact-go/v2/consumer.(*V4RequestBuilder).Header(0xc00019a5b0, {0xcfed62, 0xc}, {0xc0001b9ca8, 0x1, 0x41662d?})
        /app/consumer/http_v4.go:151 +0x396
github.com/pact-foundation/pact-go/v2/consumer.TestHttpV4TypeSystem.func1(0xc00019a5b0)
        /app/consumer/http_v4_test.go:25 +0x8c
github.com/pact-foundation/pact-go/v2/consumer.(*V4UnconfiguredInteraction).WithRequestPathMatcher(0xc00019a560, {0xcf829c, 0x3}, {0xdfd8a0, 0xc00019a570}, {0xc0001b9e00, 0x1, 0x0?})
        /app/consumer/http_v4.go:130 +0x142
github.com/pact-foundation/pact-go/v2/consumer.(*V4UnconfiguredInteraction).WithRequest(...)
        /app/consumer/http_v4.go:122
github.com/pact-foundation/pact-go/v2/consumer.TestHttpV4TypeSystem(0xc0001d6680)
        /app/consumer/http_v4_test.go:23 +0x2e5
testing.tRunner(0xc0001d6680, 0xd3d5a0)
        /usr/local/go/src/testing/testing.go:1689 +0x21f
created by testing.(*T).Run in goroutine 1
        /usr/local/go/src/testing/testing.go:1742 +0x826

@YOU54F
Copy link
Member

YOU54F commented Apr 12, 2024

Tested against linux/arm64 and its fine against there, had to make some updates to support downloading the correct variant of the csv plugin for linux aarch64

using branch https://github.com/pact-foundation/pact-go/tree/deps/go_1_22

@YOU54F
Copy link
Member

YOU54F commented Apr 12, 2024

The error occurs if you specify -race flag in go test command.

yep can also confirm this. thanks!

TL;DR

Linux x86_64 users

  • Using GoLang 1.22.x ?
    • Resolution: disable -race
  • Need to use -race?
    • Resolution: downgrade to 1.21.x

@mefellows mefellows changed the title Runtime error occrs with golang 1.22.x Runtime error occurs with golang 1.22.x Apr 23, 2024
@mefellows
Copy link
Member

Thanks Yousaf for putting together the above. It doesn't seem to be a problem on Mac either (the OS I use for development). I'd suggest we sit on this to see where Golang takes it, and leave this as a sign-post for others.

@YOU54F
Copy link
Member

YOU54F commented May 9, 2024

Also seeing the issue on macos x86_64 solely on 1.22 when testing in GHA

@m15o
Copy link
Contributor Author

m15o commented May 28, 2024

I've filed a golang issue on this problem
golang/go#67670

@mefellows
Copy link
Member

Will be interesting to see if they come back with anything, perhaps something will jump out at the maintainers there.

I suspect they'll want a more minimal repro, as there is probably a lot of digging / effort required to reproduce with the existing repro you have provided (not your fault, but it could be any number of things in both pact-go and in the rust core, or rust libraries that export the C interface). Perhaps we could find the FFI function that's causing the problem, and create a basic C interface that does the same thing until we have a minimal FFI that reproduces the issue (if possible)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants