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

regexp: panic nil pointer dereference #56067

Closed
cuiweixie opened this issue Oct 6, 2022 · 1 comment
Closed

regexp: panic nil pointer dereference #56067

cuiweixie opened this issue Oct 6, 2022 · 1 comment

Comments

@cuiweixie
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
master

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import "regexp"

func main() {
	r, _ := regexp.Compile(`(?m)^ambiguous import: found package image in multiple modules:\s+image\s+.+\\(`)
	println(r.FindString(`ambiguous import: found package image in multiple modules:
	image ($WORK/gopath/src/a)
	 (/Users/xiecui/code/go/src/go/src/image)
`))
}

What did you expect to see?

do not panic

What did you see instead?

panic

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x90 pc=0x100f15500]

goroutine 1 [running]:
regexp.(*Regexp).doExecute(0x100f1ffca?, {0x0?, 0x0?}, {0x0?, 0x1010585b8?, 0x1400008c011?}, {0x100f20068?, 0x14000002228?}, 0x1400009cf28?, 0x100ea4064?, ...)
        /Users/xiecui/code/go/src/go/src/regexp/exec.go:527 +0x50
regexp.(*Regexp).FindString(0x100f1ffca?, {0x100f20068, 0x82})
        /Users/xiecui/code/go/src/go/src/regexp/regexp.go:852 +0x5c
main.main()
        /Users/xiecui/code/go/go_compiler/code/so/a.go:7 +0x40

@ianlancetaylor
Copy link
Contributor

Check the error result of regexp.Compile.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
@golang golang locked and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants