Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Crashes with SIGSEGV soon after configuring #347

Closed
fredcy opened this issue Mar 8, 2021 · 3 comments · May be fixed by #351
Closed

Crashes with SIGSEGV soon after configuring #347

fredcy opened this issue Mar 8, 2021 · 3 comments · May be fixed by #351

Comments

@fredcy
Copy link

fredcy commented Mar 8, 2021

Describe the bug
Bot process crashes with SIGSEGV soon after configuring it.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/matrix-org/go-neb.git to Debian 10 system with libolm3 and libolm-dev installed
  2. Build with go build
  3. Run with BIND_ADDRESS=:4050 DATABASE_TYPE=sqlite3 DATABASE_URL=go-neb.db?_busy_timeout=5000 BASE_URL=http://localhost:4050 ./go-neb
  4. From another window run the curl command to configure the client with the access_token and such.
  5. The go-neb process responds to the configuration request, and then crashes about a second later with a SIGSEGV

Expected behavior
I expected the go-neb process to continue running such that I could configure services on it and use it.

Additional context

This is running on a Debian 10 VPS at linode.com with 8 GB of RAM.

go-neb output

Here is the go-neb command and its terminal output (some PII elided):

$ BIND_ADDRESS=:4050 DATABASE_TYPE=sqlite3 DATABASE_URL=go-neb.db?_busy_timeout=5000 BASE_URL=http://localhost:4050 ./go-neb
INFO[0000] Go-NEB ({BindAddress::4050 DatabaseType:sqlite3 DatabaseURL:go-neb.db?_busy_timeout=5000 BaseURL:http://localhost:4050 LogDir: ConfigFile:})
INFO[0009] Incoming request                              req.id=wMsVHfnOmVgD req.method=POST req.path=/admin/configureClient
ERRO[0009] Failed to load next_batch token               error="sql: no rows in result set" user_id="@t3bot:ostez.com"
INFO[0009] Created new client                            auto_join_rooms=false device_id=XXXXXXXX since= sync=true user_id="@mybot:example.com"
INFO[0012] Responding (640 bytes)                        code=200 req.id=wMsVHfnOmVgD req.method=POST req.path=/admin/configureClient
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xffffffffffffffb8 pc=0x7f010b09a5a8]

runtime stack:
runtime.throw(0xcae6c5, 0x2a)
	/usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:718 +0x2e5

goroutine 9 [syscall]:
runtime.cgocall(0xb16320, 0xc002d07678, 0xc003f98000)
	/usr/local/go/src/runtime/cgocall.go:154 +0x5b fp=0xc002d07648 sp=0xc002d07610 pc=0x40f7fb
maunium.net/go/mautrix/crypto/olm._Cfunc_olm_account_generate_one_time_keys(0xc00022c000, 0x32, 0xc003f98000, 0x641, 0x0)
	_cgo_gotypes.go:138 +0x49 fp=0xc002d07678 sp=0xc002d07648 pc=0x8a0bc9
maunium.net/go/mautrix/crypto/olm.(*Account).GenOneTimeKeys.func1(0xc00023ee10, 0x32, 0xc002d07708, 0x641)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/crypto/olm/account.go:303 +0xe5 fp=0xc002d076c8 sp=0xc002d07678 pc=0x8ad065
maunium.net/go/mautrix/crypto/olm.(*Account).GenOneTimeKeys(0xc00023ee10, 0x32)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/crypto/olm/account.go:303 +0xd4 fp=0xc002d07730 sp=0xc002d076c8 pc=0x8a66f4
maunium.net/go/mautrix/crypto.(*OlmAccount).getOneTimeKeys(0xc00023ee10, 0xc0002903c0, 0x10, 0xc0002903d0, 0xa, 0x0, 0xc000000005)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/crypto/account.go:76 +0x4ee fp=0xc002d07880 sp=0xc002d07730 pc=0x8b4ece
maunium.net/go/mautrix/crypto.(*OlmMachine).ShareKeys(0xc000230070, 0x0, 0x4e, 0xc003f86cb0)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/crypto/machine.go:349 +0x79 fp=0xc002d078f0 sp=0xc002d07880 pc=0x8c3b59
maunium.net/go/mautrix/crypto.(*OlmMachine).ProcessSyncResponse(0xc000230070, 0xc002cd53f0, 0x0, 0x0)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/crypto/machine.go:158 +0x2fb fp=0xc002d07988 sp=0xc002d078f0 pc=0x8c19bb
github.com/matrix-org/go-neb/clients.(*BotClient).syncCallback(0xc000298140, 0xc002cd53f0, 0x0, 0x0, 0xcca201)
	/home/fred/projects/t3bot/go-neb-upstream/clients/bot_client.go:113 +0x75 fp=0xc002d079d8 sp=0xc002d07988 pc=0x8e0dd5
github.com/matrix-org/go-neb/clients.(*BotClient).syncCallback-fm(0xc002cd53f0, 0x0, 0x0, 0x0)
	/home/fred/projects/t3bot/go-neb-upstream/clients/bot_client.go:111 +0x51 fp=0xc002d07a10 sp=0xc002d079d8 pc=0x8eac11
maunium.net/go/mautrix.(*DefaultSyncer).ProcessResponse(0xc0000ca140, 0xc002cd53f0, 0x0, 0x0, 0x0, 0x0)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/sync.go:138 +0x110 fp=0xc002d07d28 sp=0xc002d07a10 pc=0x823370
maunium.net/go/mautrix.(*Client).Sync(0xc0001b2410, 0xc0006ac160, 0x0)
	/home/fred/go/pkg/mod/maunium.net/go/mautrix@v0.7.0/client.go:242 +0x207 fp=0xc002d07dd8 sp=0xc002d07d28 pc=0x814427
github.com/matrix-org/go-neb/clients.(*BotClient).Sync(0xc000298140)
	/home/fred/projects/t3bot/go-neb-upstream/clients/bot_client.go:170 +0x159 fp=0xc002d07fd8 sp=0xc002d07dd8 pc=0x8e1479
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc002d07fe0 sp=0xc002d07fd8 pc=0x47d621
created by github.com/matrix-org/go-neb/clients.(*Clients).initClient
	/home/fred/projects/t3bot/go-neb-upstream/clients/clients.go:417 +0xd65

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x7f00e26f9218, 0x72, 0x0)
	/usr/local/go/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc000076298, 0x72, 0x0, 0x0, 0xc8cb37)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc000076280, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:401 +0x212
net.(*netFD).accept(0xc000076280, 0x43dd41b928d76e01, 0x0, 0x0)
	/usr/local/go/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00000e138, 0x60467ebe, 0xc0000b1bd8, 0x4daf46)
	/usr/local/go/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).Accept(0xc00000e138, 0xc0000b1c28, 0x18, 0xc000000180, 0x6f3edb)
	/usr/local/go/src/net/tcpsock.go:261 +0x65
net/http.(*Server).Serve(0xc0001b82a0, 0xd740b0, 0xc00000e138, 0x0, 0x0)
	/usr/local/go/src/net/http/server.go:2981 +0x285
net/http.(*Server).ListenAndServe(0xc0001b82a0, 0xc0001b82a0, 0xc00002800e)
	/usr/local/go/src/net/http/server.go:2910 +0xba
net/http.ListenAndServe(...)
	/usr/local/go/src/net/http/server.go:3164
main.main()
	/home/fred/projects/t3bot/go-neb-upstream/goneb.go:253 +0x388

goroutine 34 [select]:
database/sql.(*DB).connectionOpener(0xc000292340, 0xd76418, 0xc00028a640)
	/usr/local/go/src/database/sql/sql.go:1133 +0xb5
created by database/sql.OpenDB
	/usr/local/go/src/database/sql/sql.go:740 +0x12a

goroutine 114 [select]:
net/http.(*persistConn).writeLoop(0xc0000ce6c0)
	/usr/local/go/src/net/http/transport.go:2382 +0xf7
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1744 +0xc9c

goroutine 33 [IO wait]:
internal/poll.runtime_pollWait(0x7f00e26f8f60, 0x72, 0xffffffffffffffff)
	/usr/local/go/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc000186418, 0x72, 0xe00, 0xe7d, 0xffffffffffffffff)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc000186400, 0xc000702000, 0xe7d, 0xe7d, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:166 +0x1d5
net.(*netFD).Read(0xc000186400, 0xc000702000, 0xe7d, 0xe7d, 0x20300000000000, 0x7f00e4239fff, 0x400)
	/usr/local/go/src/net/fd_posix.go:55 +0x4f
net.(*conn).Read(0xc000284230, 0xc000702000, 0xe7d, 0xe7d, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:183 +0x91
crypto/tls.(*atLeastReader).Read(0xc00092e120, 0xc000702000, 0xe7d, 0xe7d, 0x7f00e4084500, 0xc000044c00, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:776 +0x63
bytes.(*Buffer).ReadFrom(0xc0001b0278, 0xd68780, 0xc00092e120, 0x417905, 0xbca020, 0xc5e5e0)
	/usr/local/go/src/bytes/buffer.go:204 +0xbe
crypto/tls.(*Conn).readFromUntil(0xc0001b0000, 0xd69120, 0xc000284230, 0x5, 0xc000284230, 0x8)
	/usr/local/go/src/crypto/tls/conn.go:798 +0xf3
crypto/tls.(*Conn).readRecordOrCCS(0xc0001b0000, 0x0, 0x0, 0x446ebc)
	/usr/local/go/src/crypto/tls/conn.go:605 +0x115
crypto/tls.(*Conn).readRecord(...)
	/usr/local/go/src/crypto/tls/conn.go:573
crypto/tls.(*Conn).Read(0xc0001b0000, 0xc000703000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1276 +0x165
net/http.(*persistConn).Read(0xc0000ce6c0, 0xc000703000, 0x1000, 0x1000, 0xc0002b8000, 0xc00004ed40, 0x411735)
	/usr/local/go/src/net/http/transport.go:1922 +0x77
bufio.(*Reader).fill(0xc000102d20)
	/usr/local/go/src/bufio/bufio.go:101 +0x108
bufio.(*Reader).Peek(0xc000102d20, 0x1, 0x0, 0x1, 0x4, 0x1, 0x3)
	/usr/local/go/src/bufio/bufio.go:139 +0x4f
net/http.(*persistConn).readLoop(0xc0000ce6c0)
	/usr/local/go/src/net/http/transport.go:2083 +0x1a8
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1743 +0xc77

goroutine 14 [IO wait]:
internal/poll.runtime_pollWait(0x7f00e26f9048, 0x72, 0xffffffffffffffff)
	/usr/local/go/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc000186518, 0x72, 0x1f00, 0x1f63, 0xffffffffffffffff)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc000186500, 0xc000976000, 0x1f63, 0x1f63, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:166 +0x1d5
net.(*netFD).Read(0xc000186500, 0xc000976000, 0x1f63, 0x1f63, 0x1f5e, 0xc000976000, 0x5)
	/usr/local/go/src/net/fd_posix.go:55 +0x4f
net.(*conn).Read(0xc0000be8e8, 0xc000976000, 0x1f63, 0x1f63, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:183 +0x91
crypto/tls.(*atLeastReader).Read(0xc0005fc420, 0xc000976000, 0x1f63, 0x1f63, 0x8, 0xc000044800, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:776 +0x63
bytes.(*Buffer).ReadFrom(0xc00029e978, 0xd68780, 0xc0005fc420, 0x417905, 0xbca020, 0xc5e5e0)
	/usr/local/go/src/bytes/buffer.go:204 +0xbe
crypto/tls.(*Conn).readFromUntil(0xc00029e700, 0xd69120, 0xc0000be8e8, 0x5, 0xc0000be8e8, 0xc0007119f8)
	/usr/local/go/src/crypto/tls/conn.go:798 +0xf3
crypto/tls.(*Conn).readRecordOrCCS(0xc00029e700, 0x0, 0x0, 0x446ebc)
	/usr/local/go/src/crypto/tls/conn.go:605 +0x115
crypto/tls.(*Conn).readRecord(...)
	/usr/local/go/src/crypto/tls/conn.go:573
crypto/tls.(*Conn).Read(0xc00029e700, 0xc000678000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1276 +0x165
net/http.(*persistConn).Read(0xc0002ea6c0, 0xc000678000, 0x1000, 0x1000, 0xc00008e120, 0xc000711d40, 0x411735)
	/usr/local/go/src/net/http/transport.go:1922 +0x77
bufio.(*Reader).fill(0xc00028d380)
	/usr/local/go/src/bufio/bufio.go:101 +0x108
bufio.(*Reader).Peek(0xc00028d380, 0x1, 0x0, 0x1, 0x4, 0x1, 0x3)
	/usr/local/go/src/bufio/bufio.go:139 +0x4f
net/http.(*persistConn).readLoop(0xc0002ea6c0)
	/usr/local/go/src/net/http/transport.go:2083 +0x1a8
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1743 +0xc77

goroutine 15 [select]:
net/http.(*persistConn).writeLoop(0xc0002ea6c0)
	/usr/local/go/src/net/http/transport.go:2382 +0xf7
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1744 +0xc9c

My configuration command has this shape:

curl -X POST localhost:4050/admin/configureClient --data-binary '{
    "UserID": "@mybot.example.com",
    "HomeserverURL": "https://example.com:8448",
    "AccessToken": "XXXXXXXXXX",
    "DeviceID": "ZZZZZZZZZZ",
    "Sync": true,
    "AutoJoinRooms": false,
    "DisplayName": "My Bot"
}'
@nyonson
Copy link

nyonson commented Mar 16, 2021

I am seeing the same error on an Arch system with the libolm library installed.

@Mic92
Copy link

Mic92 commented Jul 18, 2021

This might be fixed by upgrading maunium.net/go/mautrix: https://github.com/tulir/mautrix-go/releases/tag/v0.8.0

@daenney
Copy link
Contributor

daenney commented Jul 21, 2021

This should be fixed now that #350 got merged. I'll close it for now, please reopen it if the issue persists.

@daenney daenney closed this as completed Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants