Skip to content

Tested documenation example from go1.15-1.18, get nil pointer dereference #266

@dmitridb

Description

@dmitridb

Hello;

When attempting to build the example in the documentation with latest version of the go compiler ( go 1.18 ):

$ go run main.go
2022/03/30 10:59:32 RegisterViewPathError: github.com/qor/admin/views not found!

[2022-03-30 10:59:32] [info] registering callback `qor_admin:composite_primary_key` from /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/composite_primary_key_callback.go:34

[2022-03-30 10:59:32] [info] registering callback `qor_admin:composite_primary_key` from /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/composite_primary_key_callback.go:39
Listening on: 9000
2022/03/30 10:59:38 Finish [GET] /admin Took 0.06ms
2022/03/30 10:59:38 http: panic serving 127.0.0.1:59800: runtime error: invalid memory address or nil pointer dereference
goroutine 20 [running]:
net/http.(*conn).serve.func1()
        /usr/lib/go/src/net/http/server.go:1825 +0xbf
panic({0x988a40, 0xd66080})
        /usr/lib/go/src/runtime/panic.go:844 +0x258
html/template.(*Template).escape(0x0)
        /usr/lib/go/src/html/template/template.go:97 +0x34
html/template.(*Template).Execute(0x0, {0xacd480, 0xc0002ea380}, {0x9ed260, 0xc00040f420})
        /usr/lib/go/src/html/template/template.go:121 +0x32
github.com/qor/admin.(*Context).Execute(0xc00040f420, {0x9f66dd?, 0x0?}, {0x0?, 0x0})
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/context.go:227 +0x2d9
github.com/qor/admin.(*Controller).Dashboard(0x969380?, 0xc0004378c0?)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/controller.go:28 +0x2c
github.com/qor/admin.(*Admin).NewServeMux.func2(0xc00040f420, 0x9d4480?)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/route.go:197 +0x183
github.com/qor/admin.Middleware.Next(...)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/route.go:38
github.com/qor/admin.(*Admin).NewServeMux.func1(0xc00040f420, 0xc0004401a0)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/route.go:187 +0x1d3
github.com/qor/admin.Middleware.Next(...)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/route.go:38
github.com/qor/admin.Admin.registerCompositePrimaryKeyCallback.func1(0xc00040f420, 0xc00032f760)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/composite_primary_key_callback.go:27 +0x1f1
github.com/qor/admin.(*serveMux).ServeHTTP(0x7f8c659912e8?, {0xacf6c0?, 0xc0002ea380}, 0xc0001c5a00)
        /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/route.go:288 +0x94f
net/http.(*ServeMux).ServeHTTP(0x0?, {0xacf6c0, 0xc0002ea380}, 0xc0001c5a00)
        /usr/lib/go/src/net/http/server.go:2462 +0x149
net/http.serverHandler.ServeHTTP({0xc00042fe90?}, {0xacf6c0, 0xc0002ea380}, 0xc0001c5a00)
        /usr/lib/go/src/net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc00043e320, {0xacf948, 0xc00042fda0})
        /usr/lib/go/src/net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
        /usr/lib/go/src/net/http/server.go:3071 +0x4db

Same results tested back to go 1.16

Go 1.15 (Debian 11 from package) works:


$ go run main.go
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:129019:10: warning: function may return address of local variable [-Wreturn-local-addr]
129019 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128979:10: note: declared here
128979 |   Select standin;
       |          ^~~~~~~

[2022-03-30 12:51:59] [info] registering callback `qor_admin:composite_primary_key` from /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/composite_primary_key_callback.go:34

[2022-03-30 12:51:59] [info] registering callback `qor_admin:composite_primary_key` from /home/dmitridb/go/pkg/mod/github.com/qor/admin@v1.2.0/composite_primary_key_callback.go:39
Listening on: 9000
2022/03/30 12:52:22 Finish [GET] /admin Took 3.84ms

What's missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions