codeskyblue / codeskyblue/gohttpserver

Runtime error: invalid memory address or nil pointer dereference when trying to upload file bigger than 32 MB

Open
#102 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.8k
Forks
583
PR merge metrics
No merged PRs in 30d

Description

Hi There,
I'm facing when trying to upload files bigger than 32MB, is there any configuration I can apply to solve this issue?

Launching HTTP Server Docker Image:
➜ temp docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver codeskyblue/gohttpserver --upload --delete
2020/12/14 19:39:42 httpstaticserver.go:66: root path: /app/public/
2020/12/14 19:39:43 main.go:164: plistproxy: "https://plistproxy.herokuapp.com/plist"
2020/12/14 19:39:43 main.go:212: listening on ":8000", local address http://172.17.0.2:8000
2020/12/14 19:39:44 httpstaticserver.go:78: Started making search index
2020/12/14 19:39:44 httpstaticserver.go:80: Completed search index in 3.395757ms
2020/12/14 19:39:55 main.go:55: 172.17.0.1 - POST 200 /
2020/12/14 19:40:02 httpstaticserver.go:239: Move /tmp/multipart-236259721 -> /app/public/temp_file
2020/12/14 19:40:02 httpstaticserver.go:252: Handle upload file:
2020/12/14 19:40:02 server.go:3085: http: panic serving 172.17.0.1:62756: runtime error: invalid memory address or nil pointer dereference
goroutine 13 [running]:
net/http.(*conn).serve.func1(0xc000074320)
/usr/local/go/src/net/http/server.go:1795 +0x139
panic(0x933ee0, 0xe2afd0)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
main.(*HTTPStaticServer).hUploadOrMkdir(0xc0000d4510, 0xa96a40, 0xc00008c2c0, 0xc0000d3100)
/app/gohttpserver/httpstaticserver.go:253 +0x680
net/http.HandlerFunc.ServeHTTP(0xc0000f0b70, 0xa96a40, 0xc00008c2c0, 0xc0000d3100)
/usr/local/go/src/net/http/server.go:2036 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0000b9ea0, 0xa96a40, 0xc00008c2c0, 0xc0000d3100)
/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x104
main.(*HTTPStaticServer).ServeHTTP(0xc0000d4510, 0xa96a40, 0xc00008c2c0, 0xc0000d2e00)
/app/gohttpserver/httpstaticserver.go:97 +0x50
github.com/codeskyblue/go-accesslog.(*LoggingHandler).ServeHTTP(0xc0000ed7a0, 0xa97140, 0xc000124000, 0xc0000d2e00)
/go/pkg/mod/github.com/codeskyblue/go-accesslog@v0.0.0-20171215023101-6188d3bd9371/accesslog.go:162 +0x3cf
net/http.(*ServeMux).ServeHTTP(0xe3d320, 0xa97140, 0xc000124000, 0xc0000d2e00)
/usr/local/go/src/net/http/server.go:2416 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0001242a0, 0xa97140, 0xc000124000, 0xc0000d2e00)
/usr/local/go/src/net/http/server.go:2831 +0xa4
net/http.(*conn).serve(0xc000074320, 0xa98600, 0xc00001e300)
/usr/local/go/src/net/http/server.go:1919 +0x875
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2957 +0x384

When I try to run the following cmd commands:
➜ ~ mkfile -n 32m temp_file
➜ ~ curl -F file=@temp_file localhost:8000
{"destination":"/app/public/temp_file","success":true}
➜ ~ mkfile -n 33m temp_file
➜ ~ curl -F file=@temp_file localhost:8000
curl: (52) Empty reply from server

Can you help me out with this, please?

Thanks,
Nuno Marcos

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in httpstaticserver.go at hUploadOrMkdir, especially the upload handling around line 253 shown in the stack trace. Reproduce the difference between 32 MB and 33 MB uploads with the provided Docker and curl commands, then trace the nil error path. Done means oversized uploads no longer panic and return a handled HTTP response.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.