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

[BUG] The example in validator/README.md would fail when running with -race in go1.21 #84

Open
ericuni opened this issue Aug 25, 2024 · 0 comments

Comments

@ericuni
Copy link

ericuni commented Aug 25, 2024

go test -race -v -gcflags="all=-l -N" -cover -run Example

go env output

GO111MODULE='on'
GOARCH='amd64'
GOBIN='/data00/home/liuqi.victor/go/bin'
GOCACHE='/data00/home/liuqi.victor/.cache/go-build'
GOENV='/data00/home/liuqi.victor/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/data00/home/liuqi.victor/go/pkg/mod'
GOOS='linux'
GOPATH='/data00/home/liuqi.victor/go'
GOPROXY='https://go-mod-proxy.byted.org|https://goproxy.cn|https://proxy.golang.org|direct'
GOROOT='/data00/home/liuqi.victor/sdk/go1.21.13'
GOSUMDB='sum.golang.google.cn'
GOTMPDIR='/tmp/go'
GOTOOLCHAIN='auto'
GOTOOLDIR='/data00/home/liuqi.victor/sdk/go1.21.13/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.13'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/data00/home/liuqi.victor/git/code/golang/playground/go.mod'
GOWORK='/data00/home/liuqi.victor/git/code/golang/go.work'
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/go-build1951969996=/tmp/go-build -gno-record-gcc-switches'

go test output

=== RUN   Example
runtime: pointer 0xc00029c9b0 to unused region of span span.base()=0xc000430000 span.limit=0xc000433f00 span.state=1
runtime: found in object at *(0xc0001239b0+0x8)
object=0xc0001239b0 s.base()=0xc000122000 s.limit=0xc000123fe0 s.spanclass=10 s.elemsize=48 s.state=mSpanInUse
 *(object+0) = 0xc0003efc20
 *(object+8) = 0xc00029c9b0 <==
 *(object+16) = 0xc000123740
 *(object+24) = 0x0
 *(object+32) = 0x0
 *(object+40) = 0x0
fatal error: found bad pointer in Go heap (incorrect use of unsafe or cgo?)

runtime stack:
runtime.throw({0xcdf8e0?, 0x6?})
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/panic.go:1077 +0x5c fp=0x7fd1e9ffac90 sp=0x7fd1e9ffac60 pc=0x47b8fc
runtime.badPointer(0x7fd24a74c618, 0xc0003efc20?, 0xc0001239b0, 0x2d?)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/mbitmap.go:321 +0xa5 fp=0x7fd1e9fface8 sp=0x7fd1e9ffac90 pc=0x453145
runtime.findObject(0xc00029c9b0, 0x30?, 0x7fd1e9ffad68?)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/mbitmap.go:364 +0xd9 fp=0x7fd1e9ffad38 sp=0x7fd1e9fface8 pc=0x4533b9
runtime.scanobject(0xc0001239b0, 0xc000041c40)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/mgcmark.go:1335 +0x125 fp=0x7fd1e9ffadc0 sp=0x7fd1e9ffad38 pc=0x4601a5
runtime.gcDrain(0xc000041c40, 0x3)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/mgcmark.go:1103 +0x17b fp=0x7fd1e9ffae18 sp=0x7fd1e9ffadc0 pc=0x45fa7b
runtime.gcBgMarkWorker.func2()
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/mgc.go:1368 +0x97 fp=0x7fd1e9ffae68 sp=0x7fd1e9ffae18 pc=0x45bf77
runtime.systemstack()
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/asm_amd64.s:509 +0x4a fp=0x7fd1e9ffae78 sp=0x7fd1e9ffae68 pc=0x4b2cca

...

goroutine 1 [runnable]:
regexp/syntax.(*parser).push(0xc0004a7a00, 0xc00043c000)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/syntax/parse.go:294 +0x101f fp=0xc00042a850 sp=0xc00042a848 pc=0x6a371f
regexp/syntax.(*parser).concat(0xc0004a7a00)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/syntax/parse.go:496 +0x365 fp=0xc00042a950 sp=0xc00042a850 pc=0x6a55a5
regexp/syntax.(*parser).parseVerticalBar(0xc0004a7a00)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/syntax/parse.go:1327 +0x3b fp=0xc00042a9a8 sp=0xc00042a950 pc=0x6b051b
regexp/syntax.parse({0xc000480f00, 0x165}, 0xd4)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/syntax/parse.go:948 +0x257c fp=0xc00042b1a0 sp=0xc00042a9a8 pc=0x6adafc
regexp/syntax.Parse({0xc000480f00, 0x165}, 0xd4)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/syntax/parse.go:891 +0x99 fp=0xc00042b238 sp=0xc00042b1a0 pc=0x6ab4d9
regexp.compile({0xc000480f00, 0x165}, 0xd4, 0x0)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/regexp.go:174 +0xbb fp=0xc00042b4a0 sp=0xc00042b238 pc=0x6d6f7b
regexp.Compile({0xc000480f00, 0x165})
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/regexp.go:137 +0x96 fp=0xc00042b538 sp=0xc00042b4a0 pc=0x6d6d96
regexp.MustCompile({0xc000480f00, 0x165})
        /data00/home/liuqi.victor/sdk/go1.21.13/src/regexp/regexp.go:317 +0x7f fp=0xc00042b6a0 sp=0xc00042b538 pc=0x6d905f
github.com/nyaruka/phonenumbers.regexFor({0xc000480f00, 0x165})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/nyaruka/[email protected]/phonenumbers.go:616 +0xc7 fp=0xc00042b738 sp=0xc00042b6a0 pc=0xa68f87
github.com/nyaruka/phonenumbers.isNumberMatchingDesc({0xc000373b05, 0xb}, 0xc0004a5440)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/nyaruka/[email protected]/phonenumbers.go:2096 +0x11d fp=0xc00042b840 sp=0xc00042b738 pc=0xa6c0fd
github.com/nyaruka/phonenumbers.getNumberTypeHelper({0xc000373b05, 0xb}, 0xc00049ef00)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/nyaruka/[email protected]/phonenumbers.go:2014 +0x21a fp=0xc00042ba18 sp=0xc00042b840 pc=0xa6b53a
github.com/nyaruka/phonenumbers.IsValidNumberForRegion(0xc000375c20, {0xc00032438e, 0x2})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/nyaruka/[email protected]/phonenumbers.go:2131 +0x1fa fp=0xc00042bb00 sp=0xc00042ba18 pc=0xa6c49a
github.com/nyaruka/phonenumbers.IsValidNumber(0xc000375c20)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/nyaruka/[email protected]/phonenumbers.go:2107 +0x76 fp=0xc00042bb78 sp=0xc00042bb00 pc=0xa6c256
github.com/bytedance/go-tagexpr/v2/validator.init.1.func1({0xc00037d020, 0x1, 0x1})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/func.go:95 +0x398 fp=0xc00042bce8 sp=0xc00042bb78 pc=0xc045f8
github.com/bytedance/go-tagexpr/v2/validator.RegFunc.func1({0xc00037d020, 0x1, 0x1})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/func.go:39 +0x8a fp=0xc00042bd88 sp=0xc00042bce8 pc=0xc01c8a
github.com/bytedance/go-tagexpr/v2.(*funcExprNode).Run(0xc000375b00, {0xed4ec8, 0x11d8f40}, {0xc1b2bb, 0x6}, 0xc0001239b0)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/spec_func.go:136 +0x208 fp=0xc00042bf48 sp=0xc00042bd88 pc=0xbd15a8
github.com/bytedance/go-tagexpr/v2.(*groupExprNode).Run(0xc0000e5e40, {0xed4ec8, 0x11d8f40}, {0xc1b2bb, 0x6}, 0xc0001239b0)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/spec_operand.go:57 +0x125 fp=0xc00042c010 sp=0xc00042bf48 pc=0xbd4445
github.com/bytedance/go-tagexpr/v2.(*Expr).run(0xc00037ce20, {0xc1b2bb, 0x6}, 0xc0001239b0)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/expr.go:170 +0xe3 fp=0xc00042c0b8 sp=0xc00042c010 pc=0xbccae3
github.com/bytedance/go-tagexpr/v2.(*ExprHandler).Eval(0xc0002b8140)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/handler.go:105 +0x17c fp=0xc00042c178 sp=0xc00042c0b8 pc=0xbced9c
github.com/bytedance/go-tagexpr/v2/validator.(*Validator).Validate.func1.1(0xc0002b8140)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/validator.go:78 +0x125 fp=0xc00042c538 sp=0xc00042c178 pc=0xc034a5
github.com/bytedance/go-tagexpr/v2.(*TagExpr).Range(0xc0001239b0, 0xc000123b30)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/tagexpr.go:889 +0x1be8 fp=0xc00042ce18 sp=0xc00042c538 pc=0xbf11e8
github.com/bytedance/go-tagexpr/v2/validator.(*Validator).Validate.func1(0xc0001239b0, {0x0, 0x0})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/validator.go:74 +0x52b fp=0xc00042cf70 sp=0xc00042ce18 pc=0xc032ab
github.com/bytedance/go-tagexpr/v2.(*VM).subRunAll(0xc0002a1f80, 0x0, {0x0, 0x0}, {0xc28ac0, 0xc00029c9b0, 0x16}, 0xc00029b8e8)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/tagexpr.go:199 +0xa2c fp=0xc00042d5e0 sp=0xc00042cf70 pc=0xbe324c
github.com/bytedance/go-tagexpr/v2.(*VM).RunAny(0xc0002a1f80, {0xc28ac0, 0xc00029c9b0}, 0xc00029b8e8)
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/tagexpr.go:166 +0x22e fp=0xc00042d6f8 sp=0xc00042d5e0 pc=0xbe254e
github.com/bytedance/go-tagexpr/v2/validator.(*Validator).Validate(0xc00037c960, {0xc28ac0, 0xc00029c9b0}, {0x0, 0x0, 0x0})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/validator.go:65 +0x367 fp=0xc00042d918 sp=0xc00042d6f8 pc=0xc028a7
github.com/bytedance/go-tagexpr/v2/validator.Validate({0xc28ac0, 0xc00029c9b0}, {0x0, 0x0, 0x0})
        /data00/home/liuqi.victor/go/pkg/mod/github.com/bytedance/go-tagexpr/[email protected]/validator/default.go:17 +0xca fp=0xc00042d9b0 sp=0xc00042d918 pc=0xc0178a
playground.Example()
        /data00/home/liuqi.victor/git/code/golang/playground/playground_test.go:27 +0x39b fp=0xc00042f068 sp=0xc00042d9b0 pc=0xc04efb
testing.runExample({{0xcc9b5a, 0x7}, 0xe41738, {0xce2c79, 0x236}, 0x0})
        /data00/home/liuqi.victor/sdk/go1.21.13/src/testing/run_example.go:63 +0xa93 fp=0xc00042f3a0 sp=0xc00042f068 pc=0x733213
testing.runExamples(0xc00042fcd0, {0x119b7a0, 0x1, 0x1})
        /data00/home/liuqi.victor/sdk/go1.21.13/src/testing/example.go:44 +0x485 fp=0xc00042f598 sp=0xc00042f3a0 pc=0x726b65
testing.(*M).Run(0xc0003efa40)
        /data00/home/liuqi.victor/sdk/go1.21.13/src/testing/testing.go:1927 +0x1938 fp=0xc00042fe20 sp=0xc00042f598 pc=0x745df8
main.main()
        _testmain.go:81 +0x245 fp=0xc00042ff68 sp=0xc00042fe20 pc=0xc08ea5
runtime.main()
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/proc.go:267 +0x267 fp=0xc00042ffe0 sp=0xc00042ff68 pc=0x47e187
runtime.goexit()
        /data00/home/liuqi.victor/sdk/go1.21.13/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00042ffe8 sp=0xc00042ffe0 pc=0x4b4c41

@ericuni ericuni changed the title The example in validator/README.md would fail when running with -race in go1.21 [BUG] The example in validator/README.md would fail when running with -race in go1.21 Aug 30, 2024
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

No branches or pull requests

1 participant