Cannot test with -race #5

Open
opened 2023-07-28 02:45:28 +00:00 by Ghost · 1 comment

If run following test case with go test -race, a panic fatal error: checkptr: pointer arithmetic result points to invalid allocation will occur.

import (
	"testing"

	"go.elara.ws/pcre"
)

func TestRegex(t *testing.T) {
	regex := pcre.MustCompile(`varnish(?: \(Varnish\/([\d.]{1,250})\))?`)
	regex.MatchString("1.1 varnish")
}

Some traceback message:

goroutine 35 [running]:
runtime.throw({0x101af773d?, 0x1015e4a64?})
	runtime/panic.go:1047 +0x40 fp=0xc000385890 sp=0xc000385860 pc=0x100c00cf0
runtime.checkptrArithmetic(0xc0001d95e0?, {0x0, 0x0, 0x10?})
	runtime/checkptr.go:69 +0xac fp=0xc0003858c0 sp=0xc000385890 pc=0x100bd086c
modernc.org/libc.Xmemchr(...)
	modernc.org/libc@v1.16.8/libc.go:835
go.elara.ws/pcre/lib.Xpcre2_match_8(0xc0001d95e0, 0x12d000320, 0xc000385e60, 0xb, 0x0, 0x0, 0x12d5000a0, 0x12d500020)
	go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/lib/pcre2_darwin_arm64.go:60774 +0x518c fp=0xc000385ba0 sp=0xc0003858c0 pc=0x1015e6d8c
go.elara.ws/pcre.(*Regexp).match(0xc0000b1a80, {0xc000385e60, 0xb, 0xc0001d95e0?}, 0x2d2c78?, 0x0)
	go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:678 +0x298 fp=0xc000385db0 sp=0xc000385ba0 pc=0x1015fe228
go.elara.ws/pcre.(*Regexp).Find(0x101ae8bd9?, {0xc000385e60, 0xb, 0x20})
	go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:129 +0x4c fp=0xc000385e30 sp=0xc000385db0 pc=0x1015f9bdc
go.elara.ws/pcre.(*Regexp).MatchString(...)
	go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:377
If run following test case with `go test -race`, a panic `fatal error: checkptr: pointer arithmetic result points to invalid allocation` will occur. ```go import ( "testing" "go.elara.ws/pcre" ) func TestRegex(t *testing.T) { regex := pcre.MustCompile(`varnish(?: \(Varnish\/([\d.]{1,250})\))?`) regex.MatchString("1.1 varnish") } ``` Some traceback message: ``` goroutine 35 [running]: runtime.throw({0x101af773d?, 0x1015e4a64?}) runtime/panic.go:1047 +0x40 fp=0xc000385890 sp=0xc000385860 pc=0x100c00cf0 runtime.checkptrArithmetic(0xc0001d95e0?, {0x0, 0x0, 0x10?}) runtime/checkptr.go:69 +0xac fp=0xc0003858c0 sp=0xc000385890 pc=0x100bd086c modernc.org/libc.Xmemchr(...) modernc.org/libc@v1.16.8/libc.go:835 go.elara.ws/pcre/lib.Xpcre2_match_8(0xc0001d95e0, 0x12d000320, 0xc000385e60, 0xb, 0x0, 0x0, 0x12d5000a0, 0x12d500020) go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/lib/pcre2_darwin_arm64.go:60774 +0x518c fp=0xc000385ba0 sp=0xc0003858c0 pc=0x1015e6d8c go.elara.ws/pcre.(*Regexp).match(0xc0000b1a80, {0xc000385e60, 0xb, 0xc0001d95e0?}, 0x2d2c78?, 0x0) go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:678 +0x298 fp=0xc000385db0 sp=0xc000385ba0 pc=0x1015fe228 go.elara.ws/pcre.(*Regexp).Find(0x101ae8bd9?, {0xc000385e60, 0xb, 0x20}) go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:129 +0x4c fp=0xc000385e30 sp=0xc000385db0 pc=0x1015f9bdc go.elara.ws/pcre.(*Regexp).MatchString(...) go.elara.ws/pcre@v0.0.0-20230726053529-6d906d55a6d2/pcre.go:377 ```
Author

I'm using Darwin ARM64, but the same error occurs on Linux AMD64 too

I'm using Darwin ARM64, but the same error occurs on Linux AMD64 too
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Elara6331/pcre#5
No description provided.