cache-handler icon indicating copy to clipboard operation
cache-handler copied to clipboard

runtime error: invalid memory address or nil pointer dereference

Open mattvb91 opened this issue 1 year ago • 1 comments

Trying to put together some tests for surrogate caching and cant boot the latest version.

Reproducibly: https://github.com/mattvb91/caddy-cache-surrogates-test

docker compose up

The commit before works: https://github.com/mattvb91/caddy-cache-surrogates-test/commit/817b427e1ad9f4002d128e46b42c67f6ad3ada52

caddy      | {"level":"info","ts":1719079440.4313123,"logger":"http.handlers.cache","msg":"Embedded Olric is ready for this node."}
caddy      | panic: runtime error: invalid memory address or nil pointer dereference
caddy      | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18262a8]
caddy      | 
caddy      | goroutine 1 [running]:
caddy      | go.uber.org/zap.(*Logger).clone(...)
caddy      |    go.uber.org/[email protected]/logger.go:318
caddy      | go.uber.org/zap.(*Logger).Sugar(...)
caddy      |    go.uber.org/[email protected]/logger.go:147
caddy      | github.com/darkweak/souin/pkg/surrogate/providers.(*baseStorage).init(0x40009a80f0, {0x24413c8, 0x40002df230}, {0x1e4639d, 0xe})
caddy      |    github.com/darkweak/[email protected]/pkg/surrogate/providers/common.go:119 +0x338
caddy      | github.com/darkweak/souin/pkg/surrogate/providers.generateSouinInstance(...)
caddy      |    github.com/darkweak/[email protected]/pkg/surrogate/providers/souin.go:15
caddy      | github.com/darkweak/souin/pkg/surrogate/providers.SurrogateFactory({0x24413c8, 0x40002df230}, {0x1e4639d, 0xe})
caddy      |    github.com/darkweak/[email protected]/pkg/surrogate/providers/factory.go:19 +0x1d4
caddy      | github.com/darkweak/souin/pkg/surrogate.InitializeSurrogate(...)
caddy      |    github.com/darkweak/[email protected]/pkg/surrogate/surrogate.go:82
caddy      | github.com/darkweak/souin/pkg/middleware.NewHTTPCacheHandler({0x24413c8, 0x40002df230})
caddy      |    github.com/darkweak/[email protected]/pkg/middleware/middleware.go:70 +0x270
caddy      | github.com/caddyserver/cache-handler.(*SouinCaddyMiddleware).Provision(0x40002df208, {{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000153be0, 0x2, 0x2}, {0x0, 0x0, ...}, ...})
caddy      |    github.com/caddyserver/[email protected]/httpcache.go:248 +0x19c
caddy      | github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000153be0, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/context.go:369 +0x5f8
caddy      | github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/context.go:419 +0x12c
caddy      | github.com/caddyserver/caddy/v2.Context.LoadModule({{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/context.go:200 +0x608
caddy      | github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x400016f408, {{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, {0x0, 0x0, ...}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:154 +0xbc
caddy      | github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x400016f408, 0x4, 0x0?}, {{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:209 +0xc8
caddy      | github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision(0x40009d6780, {{0x2431cf8, 0x4000317b30}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, {0x0, 0x0, ...}, ...})
caddy      |    github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/app.go:291 +0xb38
caddy      | github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x2431d30, 0x4000890f50}, 0x400026f260, 0x4000889620, {0x4000522f80, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/context.go:369 +0x5f8
caddy      | github.com/caddyserver/caddy/v2.Context.App({{0x2431d30, 0x4000890f50}, 0x400026f260, 0x4000889620, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
caddy      |    github.com/caddyserver/caddy/[email protected]/context.go:445 +0x13c
caddy      | github.com/caddyserver/caddy/v2.run.func3(...)
caddy      |    github.com/caddyserver/caddy/[email protected]/caddy.go:488
caddy      | github.com/caddyserver/caddy/v2.run(0x40002ea700?, 0x1)
caddy      |    github.com/caddyserver/caddy/[email protected]/caddy.go:493 +0x530
caddy      | github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0x4000251880, 0x331, 0x380}, 0x1)
caddy      |    github.com/caddyserver/caddy/[email protected]/caddy.go:343 +0xe4
caddy      | github.com/caddyserver/caddy/v2.changeConfig({0x1e2ac1b, 0x4}, {0x1e32580, 0x7}, {0x40005ca000, 0x986, 0x987}, {0x0, 0x0}, 0x1)
caddy      |    github.com/caddyserver/caddy/[email protected]/caddy.go:234 +0x5c0
caddy      | github.com/caddyserver/caddy/v2.Load({0x40005ca000, 0x986, 0x987}, 0x1)
caddy      |    github.com/caddyserver/caddy/[email protected]/caddy.go:133 +0x198
caddy      | github.com/caddyserver/caddy/v2/cmd.cmdRun({0x0?})
caddy      |    github.com/caddyserver/caddy/[email protected]/cmd/commandfuncs.go:231 +0x61c
caddy      | github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.1(0x40009c4608, {0x1e2ac77?, 0x4?, 0x1e2ac4b?})
caddy      |    github.com/caddyserver/caddy/[email protected]/cmd/cobra.go:137 +0x34
caddy      | github.com/spf13/cobra.(*Command).execute(0x40009c4608, {0x4000824710, 0x1, 0x1})
caddy      |    github.com/spf13/[email protected]/command.go:983 +0x840
caddy      | github.com/spf13/cobra.(*Command).ExecuteC(0x3637ea0)
caddy      |    github.com/spf13/[email protected]/command.go:1115 +0x344
caddy      | github.com/spf13/cobra.(*Command).Execute(...)
caddy      |    github.com/spf13/[email protected]/command.go:1039
caddy      | github.com/caddyserver/caddy/v2/cmd.Main()
caddy      |    github.com/caddyserver/caddy/[email protected]/cmd/main.go:75 +0x180
caddy      | main.main()
caddy      |    caddy/main.go:12 +0x1c

mattvb91 avatar Jun 22 '24 18:06 mattvb91

Hey @mattvb91 that's weird the logger is nil because it shouldn't as it takes the caddy logger itself. 🤔

darkweak avatar Jun 28 '24 09:06 darkweak