Skip to content

x/net/http2: When using large FormFile under HTTP2 and TLS, /tmp will not be cleared. #48413

Closed
golang/net
#113
@SmallTianTian

Description

@SmallTianTian

What version of Go are you using (go version)?

$ go version
go version go1.17 darwin/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE="on"
GOARCH="arm64"
GOBIN="/Users/tick/go/bin"
GOCACHE="/Users/tick/Library/Caches/go-build"
GOENV="/Users/tick/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/tick/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/tick/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gy/5ff3jzqj6gj5jc38zq91vd2h0000gn/T/go-build1908200583=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

This is my code, please generate your own certificate

package main

import (
    "fmt"
    "net/http"
)

func main() {
    han := func(rw http.ResponseWriter, r *http.Request) {
        _, fh, err := r.FormFile("test")
        if err != nil {
            rw.Write([]byte(fmt.Sprintf("read from file failed, Err: %v", err)))
            return
        }
        rw.Write([]byte(fmt.Sprintf("total %d's byte", fh.Size)))
    }

    s := &http.Server{
        Addr:    ":8080",
        Handler: http.HandlerFunc(han),
    }
    s.ListenAndServeTLS("./server.crt", "./server.key")
}

You can upload a large form using the following command.

curl -k -F 'test=@/path/to/large/file' https://localhost:8080

Note: The file must be large enough to exceed 32M for the following reasons: request form to large will create tmp to save.

// too big, write to disk and flush buffer

What did you expect to see?

At the end of the HTTP request, files in /tmp will be destroyed.

What did you see instead?

Tmp file still exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions