-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Labels
Description
The following program sometimes fails (with jpeg.errMissingFF00) and sometimes succeeds:
package main
import (
"image/jpeg"
"log"
"net/http"
)
func main() {
res, err := http.Get("https://blog.golang.org/go-programming-language-turns-two_gophers.jpg";)
if err != nil {
log.Fatal(err)
}
if res.StatusCode != 200 {
log.Fatal(res.Status)
}
if _, err := jpeg.Decode(res.Body); err != nil {
log.Fatal(err)
}
}
It depends on timing & how the network packets arrive.
The errors and intermixed successes:
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:19 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:20 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:23 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:24 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
mac:~ bradfitz$ go run d.go
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:28 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:30 invalid JPEG format: missing 0xff00 sequence
exit status 1
mac:~ bradfitz$ go run d.go
2014/11/18 18:00:31 invalid JPEG format: missing 0xff00 sequence
exit status 1
I suspect a problem with the interaction between the jpeg package's buffering and its
huffman reader.