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
bufio: uninitialised buffer in Writer causes panics and infinite loops #18211
Comments
@BoGeM the documented way to create a Please also consider asking questions like this in the go-nuts mailing list or other help forums as a first port of call. If the behaviour you are seeing is then confirmed as a bug/issue it can easily be re-raised here in the issue tracker, referencing the original thread. |
@myitcv but user can also initalize writer by calling Ok, sorry for this. Next time I will do so. |
I've always followed the guidance laid out here: https://golang.org/doc/effective_go.html#allocation_new
Hence, I first check to see whether there is an explicit constructor or
I wouldn't say an apology is needed 😄 I make the comment just to try and help keep the issue tracker focussed on things that are known to be issues (if you look at the thousands of people who potentially get notified of each issue) |
Closing because there is nothing to fix. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/albert/go"
GORACE=""
GOROOT="/Users/albert/.gostable"
GOTOOLDIR="/Users/albert/.gostable/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wp/sytm29yd1d1dclmf01xgvqbw0000gn/T/go-build808633337=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
If one will create buffer without using a constructor (
buf := new(bufio.Writer)
), then the further writes will cause panics or infinite loops depending on method one uses.E.g. https://play.golang.org/p/LBrzU6xw2Z
What did you expect to see?
Buffer will be initialised, if it's not, and the further writes will be successful.
What did you see instead?
buf.WriteString
causes an infinite loop: https://play.golang.org/p/LBrzU6xw2Z,buf.WriteRune
causes panic: https://play.golang.org/p/MAioIyqCJs,buf.WriteByte
causes panic: https://play.golang.org/p/e-JIMtF_tc,and so on.
The text was updated successfully, but these errors were encountered: