Artalk icon indicating copy to clipboard operation
Artalk copied to clipboard

panic: runtime error: invalid memory address or nil pointer dereference in using PostgreSQL

Open syhily opened this issue 2 years ago • 2 comments

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb79d74]

goroutine 73 [running]:
github.com/ArtalkJS/Artalk/internal/dao.(*Dao).DB(...)
	/source/internal/dao/base.go:33
github.com/ArtalkJS/Artalk/internal/dao.(*Dao).FindAllSites(0x0)
	/source/internal/dao/query_find.go:164 +0x34
github.com/ArtalkJS/Artalk/internal/dao.(*Dao).FindAllSitesCooked(0x40009796c8?)
	/source/internal/dao/cook.go:169 +0x28
github.com/ArtalkJS/Artalk/server/middleware.getCorsAllowOrigins(0x4000434e70)
	/source/server/middleware/cors.go:17 +0xa8
github.com/ArtalkJS/Artalk/server/middleware.CheckOriginTrusted(0x0?, {0x0, 0x0})
	/source/server/middleware/cors.go:40 +0x24
github.com/ArtalkJS/Artalk/server.cors.CorsMiddleware.func1({0x0?, 0x14cf1ef?})
	/source/server/middleware/cors.go:56 +0x30
github.com/gofiber/fiber/v2/middleware/cors.New.func1(0x40007be900)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/middleware/cors/cors.go:150 +0x1c8
github.com/gofiber/fiber/v2.(*App).next(0x40006fd400, 0x40007be900)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:145 +0x188
github.com/gofiber/fiber/v2.(*Ctx).Next(0x4000880d20?)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:1030 +0x5c
github.com/gofiber/fiber/v2/middleware/logger.New.func3(0x40007be900)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/middleware/logger/logger.go:119 +0x25c
github.com/gofiber/fiber/v2.(*App).next(0x40006fd400, 0x40007be900)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:145 +0x188
github.com/gofiber/fiber/v2.(*App).handler(0x40006fd400, 0xfe5da8?)
	/go/pkg/mod/github.com/gofiber/fiber/[email protected]/router.go:172 +0x74
github.com/valyala/fasthttp.(*Server).serveConn(0x4000876200, {0x20441b8?, 0x40007da148})
	/go/pkg/mod/github.com/valyala/[email protected]/server.go:2359 +0xdd0
github.com/valyala/fasthttp.(*workerPool).workerFunc(0x40003680a0, 0x4000875da0)
	/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:224 +0x70
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
	/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:196 +0x38
created by github.com/valyala/fasthttp.(*workerPool).getCh in goroutine 12
	/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x208

syhily avatar Apr 12 '24 13:04 syhily

Hello, I've made some tweaks to the code. Does the issue still persist after trying to upgrade to v2.8.5?

qwqcode avatar Apr 25 '24 10:04 qwqcode

I'll check it in this weekend.

syhily avatar Apr 26 '24 13:04 syhily

This error has been fixed. Thanks for your work.

syhily avatar May 05 '24 14:05 syhily