-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
calling event.CloudEvent() inside caddyevents.Handler causes panic #7026
Copy link
Copy link
Closed
Labels
bug 🐞Something isn't workingSomething isn't working
Description
After using 2.10.0 as a dependency to one event handler module I'm developing I get
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xb615c0]
when I try to call .CloudEvent on the inbound caddy.Event.
I was not getting this when calling .CloudEvent on the pre #6930 caddyevents.Event.
I don't know if it's that specific change that causes an issue but it might be a clue.
Edit: I narrowed it down to the event.Origin() part. The Origin() getter returns null on a event with the name "started".
I'm currently running this using xcaddy run with xcaddy version 0.4.4
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xb615c0]
goroutine 1 [running]:
github.com/caddyserver/caddy/v2.Event.CloudEvent({{0x0, 0x0}, 0x0, {0x5b, 0x5c, 0x7, 0xc0, 0xa9, 0x4c, 0x47, ...}, ...})
github.com/caddyserver/caddy/v2@v2.10.0/caddy.go:1109 +0xc0
github.com/kmpm/caddy-events-nats.(*NatsHandler).Handle(0xc00081ae00, {0xc0006d6f50?, 0x0?}, {{0x0, 0x0}, 0x0, {0x5b, 0x5c, 0x7, 0xc0, ...}, ...})
github.com/kmpm/caddy-events-nats@v0.0.3/module.go:192 +0x118
github.com/caddyserver/caddy/v2/modules/caddyevents.(*App).Emit(0xc0003450e0, {{0x1fa2b58, 0xc00018cae0}, 0xc0002ccae0, 0xc00026b880, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
github.com/caddyserver/caddy/v2@v2.10.0/modules/caddyevents/app.go:291 +0xe89
github.com/caddyserver/caddy/v2.Context.emitEvent(...)
github.com/caddyserver/caddy/v2@v2.10.0/context.go:285
github.com/caddyserver/caddy/v2.run(0xc0004c7620?, 0x1)
github.com/caddyserver/caddy/v2@v2.10.0/caddy.go:448 +0x524
github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0xc0001ee5a0, 0x1dc, 0x1e0}, 0x1)
github.com/caddyserver/caddy/v2@v2.10.0/caddy.go:344 +0x145
github.com/caddyserver/caddy/v2.changeConfig({0x1ab90a6, 0x4}, {0x1abffa7, 0x7}, {0xc0001ee3c0, 0x1dc, 0x1e0}, {0x0, 0x0}, 0x1)
github.com/caddyserver/caddy/v2@v2.10.0/caddy.go:235 +0x6b9
github.com/caddyserver/caddy/v2.Load({0xc0001ee3c0, 0x1dc, 0x1e0}, 0x1)
github.com/caddyserver/caddy/v2@v2.10.0/caddy.go:134 +0x22d
github.com/caddyserver/caddy/v2/cmd.cmdRun({0x0?})
github.com/caddyserver/caddy/v2@v2.10.0/cmd/commandfuncs.go:239 +0x811
github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.1(0xc00081e608, {0x1ab9102?, 0x4?, 0x1ab90d6?})
github.com/caddyserver/caddy/v2@v2.10.0/cmd/cobra.go:141 +0x2f
github.com/spf13/cobra.(*Command).execute(0xc00081e608, {0x2d4fd80, 0x0, 0x0})
github.com/spf13/cobra@v1.9.1/command.go:1015 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc00081e008)
github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.9.1/command.go:1071
github.com/caddyserver/caddy/v2/cmd.Main()
github.com/caddyserver/caddy/v2@v2.10.0/cmd/main.go:72 +0x65
main.main()
caddy/main.go:12 +0xf
Error: exit status 2
exit status 2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug 🐞Something isn't workingSomething isn't working