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: crash on illegal expression #9965

Closed
robpike opened this issue Feb 23, 2015 · 4 comments
Closed

regexp: crash on illegal expression #9965

robpike opened this issue Feb 23, 2015 · 4 comments
Assignees
Milestone

Comments

@robpike
Copy link
Contributor

@robpike robpike commented Feb 23, 2015

from stack overflow.

http://play.golang.org/p/ZGO_inicCG

package main

import (
    "fmt"
    "regexp"
)

func main() {
    r, _ := regexp.Compile("* * *")
    r2 := r.ReplaceAll([]byte("* * *"), []byte("<hr>"))
    fmt.Println(r2)
}


panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x8c0c2]

goroutine 1 [running]:
regexp.(*Regexp).get(0x0, 0x512a, 0x104400f0, 0x178c0e)
    /usr/src/go/src/regexp/regexp.go:192 +0x1e2
regexp.(*Regexp).doExecute(0x0, 0x0, 0x0, 0x10436190, 0x5, 0x8, 0x0, 0x0, 0x0, 0x2, ...)
    /usr/src/go/src/regexp/exec.go:423 +0x80
regexp.(*Regexp).replaceAll(0x0, 0x10436190, 0x5, 0x8, 0x0, 0x0, 0x2, 0x1041971c, 0x0, 0x0, ...)
    /usr/src/go/src/regexp/regexp.go:486 +0x120
regexp.(*Regexp).ReplaceAll(0x0, 0x10436190, 0x5, 0x8, 0x10436198, 0x4, 0x8, 0x512a, 0x0, 0x0, ...)
    /usr/src/go/src/regexp/regexp.go:549 +0x140
main.main()
    /tmp/sandbox739482667/main.go:10 +0x160
@robpike robpike added this to the Go1.5 milestone Feb 23, 2015
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Feb 23, 2015

What's the bug? It should crash earlier? r is nil.

@randall77
Copy link
Contributor

@randall77 randall77 commented Feb 23, 2015

The ignored error is:
error parsing regexp: missing argument to repetition operator: *

On Mon, Feb 23, 2015 at 12:24 PM, Brad Fitzpatrick <notifications@github.com

wrote:

What's the bug? It should crash earlier? r is nil.


Reply to this email directly or view it on GitHub
#9965 (comment).

@minux
Copy link
Member

@minux minux commented Feb 23, 2015

@robpike
Copy link
Contributor Author

@robpike robpike commented Feb 24, 2015

Sorry for the noise.

@robpike robpike closed this Feb 24, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.