Slightly simplified version:

==> go.mod <==
module example.com

go 1.20

==> main.go <==
package main

import (
"plugin"
"regexp/syntax"
)

func main() {
if syntax.Perl != 212 {
panic("Unexpected flags")
}

p, err := plugin.Open("p1.so")
if err != nil {
panic(err)
}
s, err := p.Lookup("F")
if err != nil {
panic(err)
}

f := s.(func())
f()
}

==> p1/plugin.go <==
package main

import (
"regexp"
)

func F() {
_ = regexp.MustCompile(`\w+`)
}

func main() {}


FWIW, it also fails in the same way on macOS:

$ go build -buildmode=plugin ./p1 && go run main.go
panic: regexp: Compile(`\w+`): error parsing regexp: invalid escape 
sequence: `\w`

goroutine 1 [running]:
regexp.MustCompile({0x107aa6eea, 0x3})
/usr/local/go/src/regexp/regexp.go:319 +0xb4
example.com/p1.F()
/Users/brian/tmp/go/62430/p1/plugin.go:8 +0x1f
main.main()
/Users/brian/tmp/go/62430/main.go:23 +0x103
exit status 2

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e6767616-877e-4362-9c2f-21522646ccc9n%40googlegroups.com.

Reply via email to