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

crash in client.go #74

Open
catalinii opened this issue Sep 22, 2021 · 3 comments
Open

crash in client.go #74

catalinii opened this issue Sep 22, 2021 · 3 comments
Labels

Comments

@catalinii
Copy link

catalinii commented Sep 22, 2021

The gofast is setup to interact with the php7.4-fpm and I get the crash of the app with the following log messages:

2021/09/22 11:24:31 gofast: error writing error buffer to response: gofast: copy error: write tcp 10.0.255.150:443->54.36.148.120:37375: write: connection reset by peer 2021/09/22 11:24:31 gofast: error stream from application process gofast: timeout or canceled panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x2939d4]

goroutine 72774 [running]:
github.com/yookoala/gofast.(*client).readResponse.func1(0x400051e000, 0x40003fa440, 0x40001a4a80, 0x400007aae0)
/root/go/pkg/mod/github.com/yookoala/gofast@v0.6.0/client.go:213 +0x24
created by github.com/yookoala/gofast.(*client).readResponse
/root/go/pkg/mod/github.com/yookoala/gofast@v0.6.0/client.go:210 +0x84
exit status 2

@yookoala
Copy link
Owner

Can you show more of your code?

It's hard to tell what happened without further information.

@catalinii
Copy link
Author

catalinii commented Sep 23, 2021

func forum(w http.ResponseWriter, r *http.Request) {
        log.Printf("php %v %v", r.RemoteAddr, r.URL.Path)
        cgi.ServeHTTP(w, r)
}

func main() {
        connFactory := gofast.SimpleConnFactory("unix", "/run/php/php7.4-fpm.sock")
        ssl := http.NewServeMux()

        // handles static assets in the assets folder
        file = http.FileServer(http.FileSystem(http.Dir(DOC_ROOT)))
        ssl.HandleFunc("/forum/", forum)
        cgi = gofast.NewHandler(
                gofast.NewPHPFS(DOC_ROOT)(gofast.BasicSession),
                gofast.SimpleClientFactory(connFactory),
        )
        cfg := &tls.Config{
                MinVersion:               tls.VersionTLS12,
                CurvePreferences:         []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
                PreferServerCipherSuites: true,
                CipherSuites: []uint16{
                        tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
                },
        }
        srv := &http.Server{
                Addr:         ":443",
                Handler:      ssl,
                TLSConfig:    cfg,
                TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
        }
       
        // serve at ssl port
        log.Fatal(srv.ListenAndServeTLS("fullchain.pem", "privkey.pem"))

Forgot to mention, this happens after running for multiple hours.

@yookoala
Copy link
Owner

Thanks. Will check this issue.

@yookoala yookoala added the bug label Sep 24, 2021
yookoala added a commit that referenced this issue Aug 3, 2022
possible fix of invalid memory address dereference (#74 and #48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants