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

generate.vim: data race in VimBuffer #377

Closed
ezradiniz opened this issue Apr 4, 2021 · 0 comments · Fixed by #378
Closed

generate.vim: data race in VimBuffer #377

ezradiniz opened this issue Apr 4, 2021 · 0 comments · Fixed by #378
Assignees
Labels

Comments

@ezradiniz
Copy link
Contributor

I ran the vim-bootstrap-server and hit a data race requesting several configurations at the same time.

#!/usr/bin/env bash

theme="$1"

while true; do
    colorscheme=$(curl -sS -d "theme=$theme"  http://localhost:3000/generate.vim | grep colorscheme)
    if [ "$colorscheme" == "colorscheme $theme" ]; then
        echo "Ok: $colorscheme"
    else
        echo "Bad: $colorscheme"
        exit 1
    fi
done

Try to run the above script at the same time and you will have a data race.

# Run this at same time
$ ./run.sh wombat
$ ./run.sh molokai
Data race output
WARNING: DATA RACE
Read at 0x00c000237118 by goroutine 87:
runtime.slicecopy()
    /usr/lib/go/src/runtime/slice.go:247 +0x0
bytes.(*Buffer).grow()
    /usr/lib/go/src/bytes/buffer.go:143 +0x269
bytes.(*Buffer).Write()
    /usr/lib/go/src/bytes/buffer.go:172 +0x184
text/template.(*state).walk()
    /usr/lib/go/src/text/template/exec.go:271 +0x747
text/template.(*state).walk()
    /usr/lib/go/src/text/template/exec.go:264 +0x1a4
text/template.(*Template).execute()
    /usr/lib/go/src/text/template/exec.go:220 +0x2fb
text/template.(*Template).Execute()
    /usr/lib/go/src/text/template/exec.go:203 +0xaa4
github.com/editor-bootstrap/vim-bootstrap/generate.Generate()
    /home/ezra/dev/thirdparty/vim-bootstrap/generate/generate.go:130 +0xa66
github.com/editor-bootstrap/vim-bootstrap/web.HandleGenerate()
    /home/ezra/dev/thirdparty/vim-bootstrap/web/web.go:49 +0x484
net/http.HandlerFunc.ServeHTTP()
    /usr/lib/go/src/net/http/server.go:2069 +0x51
github.com/gorilla/mux.(*Router).ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x132
github.com/urfave/negroni.Wrap.func1()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:46 +0x68
github.com/urfave/negroni.HandlerFunc.ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:29 +0x5b
github.com/urfave/negroni.middleware.ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38 +0x116
github.com/urfave/negroni.middleware.ServeHTTP-fm()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:37 +0x7e
github.com/urfave/negroni.(*Static).ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/static.go:34 +0x99b
github.com/urfave/negroni.middleware.ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38 +0x116
github.com/urfave/negroni.middleware.ServeHTTP-fm()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:37 +0x7e
github.com/urfave/negroni.(*Logger).ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/logger.go:62 +0x9c
github.com/urfave/negroni.middleware.ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38 +0x116
github.com/urfave/negroni.middleware.ServeHTTP-fm()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:37 +0x7e
github.com/urfave/negroni.(*Recovery).ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/recovery.go:193 +0xd6
github.com/urfave/negroni.middleware.ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38 +0x116
github.com/urfave/negroni.(*Negroni).ServeHTTP()
    /home/ezra/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:96 +0x186
net/http.serverHandler.ServeHTTP()
    /usr/lib/go/src/net/http/server.go:2887 +0xca
net/http.(*conn).serve()
    /usr/lib/go/src/net/http/server.go:1952 +0x87d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants