jhalter / mobius

A Hotline server implemented in Golang for macOS, Linux, and Windows operating systems
MIT License
73 stars 8 forks source link

Server crashes on incorrect post news request #147

Closed tjohnman closed 1 month ago

tjohnman commented 1 month ago

I'm implementing news posting in my Hotline client, and while testing it on a local Mobius instance, the server crashed. I'm pretty sure I must be sending the transaction wrong, since this was my first test, but just in case you want to take a look at it, this is the traceback.

stacktrace from panic:
goroutine 249 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.22.4/x64/src/runtime/debug/stack.go:24 +0x5e
github.com/jhalter/mobius/hotline.dontPanic(0xc00002e640)
        /home/runner/work/mobius/mobius/hotline/panic.go:12 +0x4a
panic({0x1146120?, 0xc0001e2048?})
        /opt/hostedtoolcache/go/1.22.4/x64/src/runtime/panic.go:770 +0x132
github.com/jhalter/mobius/internal/mobius.(*ThreadedNewsYAML).PostArticle(0xc000073840, {0x15555a0, 0x0, 0x0}, 0x0, {{0xc0001e2018, 0x11}, {0xc0001d00c8, 0x3}, {0x7, ...}, ...})
        /home/runner/work/mobius/mobius/internal/mobius/threaded_news.go:132 +0x4e5
github.com/jhalter/mobius/internal/mobius.HandlePostNewsArt(0xc000096000, 0xc00011e100)
        /home/runner/work/mobius/mobius/internal/mobius/transaction_handlers.go:1229 +0x919
github.com/jhalter/mobius/hotline.(*ClientConn).handleTransaction(0xc000096000, {0x0, 0x0, {0x1, 0x9a}, {0x0, 0x0, 0x0, 0x4}, {0x0, ...}, ...})
        /home/runner/work/mobius/mobius/hotline/client_conn.go:110 +0x173
github.com/jhalter/mobius/hotline.(*Server).handleNewConnection(0xc000065880, {0x1159fc0?, 0x15555a0?}, {0x259fe812cb8, 0xc00028e000}, {0xc00000a0e0, 0xb})
        /home/runner/work/mobius/mobius/hotline/server.go:494 +0x2873
github.com/jhalter/mobius/hotline.(*Server).Serve.func1()
        /home/runner/work/mobius/mobius/hotline/server.go:226 +0x250
created by github.com/jhalter/mobius/hotline.(*Server).Serve in goroutine 12
        /home/runner/work/mobius/mobius/hotline/server.go:218 +0x190

time=2024-07-23T22:43:14+02:00 level=ERROR msg=PANIC err="runtime error: slice bounds out of range [:-1]" trace="goroutine 249 [running]:\nruntime/debug.Stack()\n\t/opt/hostedtoolcache/go/1.22.4/x64/src/runtime/debug/stack.go:24 +0x5e\ngiub.com/jhalter/mobius/hotline.dontPanic(0xc00002e640)\n\t/home/runner/work/mobius/mobius/hotline/panic.go:13 +0xb0\npanic({0x1146120?, 0xc0001e2048?})\n\t/opt/hostedtoolcache/go/1.22.4/x64/src/runtime/panic.go:770 +0x132\ngithub.com/jhalt/mobius/internal/mobius.(*ThreadedNewsYAML).PostArticle(0xc000073840, {0x15555a0, 0x0, 0x0}, 0x0, {{0xc0001e2018, 0x11}, {0xc0001d00c8, 0x3}, {0x7, ...}, ...})\n\t/home/runner/work/mobius/mobius/internal/mobius/threaded_news.go:132 +0x4e5github.com/jhalter/mobius/internal/mobius.HandlePostNewsArt(0xc000096000, 0xc00011e100)\n\t/home/runner/work/mobius/mobius/internal/mobius/transaction_handlers.go:1229 +0x919\ngithub.com/jhalter/mobius/hotline.(*ClientConn).handleTransactn(0xc000096000, {0x0, 0x0, {0x1, 0x9a}, {0x0, 0x0, 0x0, 0x4}, {0x0, ...}, ...})\n\t/home/runner/work/mobius/mobius/hotline/client_conn.go:110 +0x173\ngithub.com/jhalter/mobius/hotline.(*Server).handleNewConnection(0xc000065880, {0x1159fc0 0x15555a0?}, {0x259fe812cb8, 0xc00028e000}, {0xc00000a0e0, 0xb})\n\t/home/runner/work/mobius/mobius/hotline/server.go:494 +0x2873\ngithub.com/jhalter/mobius/hotline.(*Server).Serve.func1()\n\t/home/runner/work/mobius/mobius/hotline/servego:226 +0x250\ncreated by github.com/jhalter/mobius/hotline.(*Server).Serve in goroutine 12\n\t/home/runner/work/mobius/mobius/hotline/server.go:218 +0x190\n"

I'll be glad to offer more information if you need it.

jhalter commented 1 month ago

Thanks, will fix!

Also, what's your Hotline client?

jhalter commented 1 month ago

Just released v0.14.1 with a fix. Missing paths in the news transactions should fail with an error instead of panicking.

tjohnman commented 1 month ago

Thanks, will fix!

Also, what's your Hotline client?

Thank you. It's https://github.com/tjohnman/Obsession I edited the opening message and linked to it.

jhalter commented 1 month ago

Fixed in #148, probably