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

x/image/webp: excessive memory consumption (2) #11395

dvyukov opened this issue Jun 25, 2015 · 2 comments

x/image/webp: excessive memory consumption (2) #11395

dvyukov opened this issue Jun 25, 2015 · 2 comments


Copy link

dvyukov commented Jun 25, 2015

The following program crashes as follows:

package main

import (

func main() {
    cfg, err := webp.DecodeConfig(bytes.NewReader(data))
    if err != nil {
    fmt.Printf("decoding %+v\n", cfg)

var data = []byte("RIFF,-\x00\x00WEBPVP8X\n\x00\x00\x00" +
    "\x10\x00\x00\x00\x8f\x01\x00,\x01\x00VP8X\n\x00\x00\x00\x10\xb2" +
    "\x01\x00\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00" +
    "\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00W" +
    "EB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB" +
    "\x01\x00VP8X\n\x00\x00\x00\x10\x00\x90X\x00\x00WEB\x00" +
    "ALPHPVP8X\n\x00\x00\x00\x10\x00\x00\x00\x8f\x01\x00" +
    ",\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB\x01" +
    "\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WE\u007f\x00\x00\x00" +
    "P893\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB\x01\x00VP" +
    "8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB\x01\x00VP8X" +
decoding {ColorModel:0xc8200d0068 Width:400 Height:301}
fatal error: runtime: out of memory

runtime.mallocgc(0x1685ca4246, 0x4ecfc0, 0xc800000001, 0x5f03c0)
    src/runtime/malloc.go:635 +0x972 fp=0xc82007da68 sp=0xc82007d998
runtime.newarray(0x4ecfc0, 0x1685ca4246, 0x1)
    src/runtime/malloc.go:759 +0xc9 fp=0xc82007daa8 sp=0xc82007da68
runtime.makeslice(0x4e5a40, 0x1685ca4246, 0x1685ca4246, 0x0, 0x0, 0x0)
    src/runtime/slice.go:32 +0x165 fp=0xc82007daf8 sp=0xc82007daa8, 0xc8200d00b0, 0x424500570000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/ +0xa9 fp=0xc82007dc28 sp=0xc82007daf8, 0xc8200ae270, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    src/ +0x56c fp=0xc82007ddd8 sp=0xc82007dc28, 0xc8200ae270, 0x0, 0x0, 0x0, 0x0)
    src/ +0x52 fp=0xc82007de38 sp=0xc82007ddd8
    webp.go:15 +0x2da fp=0xc82007df50 sp=0xc82007de38

Image size is 400x301, but the code tries to allocate 96 gigs of memory for decoding. This looks wrong.

on commit eb11b45157c1b71f30b3cec66306f1cd779a689e

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jul 11, 2015
Copy link

This issue was related to #16236, and got fixed in CL 24638. So, this can be closed.

Copy link

Thanks, closing.

@golang golang locked and limited conversation to collaborators Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

5 participants