Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TeleIRC crashing #434

Open
BigErn77 opened this issue Feb 5, 2025 · 9 comments
Open

TeleIRC crashing #434

BigErn77 opened this issue Feb 5, 2025 · 9 comments
Assignees
Labels
bug Something isn't working Telegram Issues relating to Telegram bridge
Milestone

Comments

@BigErn77
Copy link

BigErn77 commented Feb 5, 2025

I get these errors a lot. Usually I can just run teleirc again and it starts fine. But after an hour or so it crashes with the same error.

$ ./teleirc
INFO: 2025/02/05 00:31:18 Current TeleIRC version: v2.3.0-10-g0af3dfe
INFO: 2025/02/05 00:31:18 Creating new Telegram bot client...
INFO: 2025/02/05 00:31:18 Creating new IRC bot client...
INFO: 2025/02/05 00:31:18 Starting up Telegram bot...
INFO: 2025/02/05 00:31:18 Starting up IRC bot...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x10e839f]

goroutine 23 [running]:
github.com/go-telegram-bot-api/telegram-bot-api.(*BotAPI).MakeRequest(0x0, {0x11e77c1, 0xb}, 0xc0002c7a70)
C:/Users/biger/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api@v4.6.4+incompatible/bot.go:64 +0x7f
github.com/go-telegram-bot-api/telegram-bot-api.(*BotAPI).makeMessageRequest(, {, }, )
C:/Users/biger/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api@v4.6.4+incompatible/bot.go:119 +0x7b
github.com/go-telegram-bot-api/telegram-bot-api.(*BotAPI).sendChattable(
, {
, })
C:/Users/biger/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api@v4.6.4+incompatible/bot.go:343 +0xd0
github.com/go-telegram-bot-api/telegram-bot-api.(*BotAPI).Send(
, {_, _})
C:/Users/biger/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api@v4.6.4+incompatible/bot.go:274 +0xb8
github.com/ritlug/teleirc/internal/handlers/telegram.(*Client).SendMessage(0xc0001cce80, {0xc0002410c0?, 0xc000305c50?})
C:/dev/src/teleirc/internal/handlers/telegram/telegram.go:37 +0xc8
github.com/ritlug/teleirc/internal/handlers/irc.Client.SendToTg(...)
C:/dev/src/teleirc/internal/handlers/irc/irc.go:123
github.com/ritlug/teleirc/internal/handlers/irc.disconnectHandler.func1(0xf232cf?, {0x0, 0x0, {0x0, 0x0, 0x0}, {0x11eae0f, 0x13}, {0xc000289260, 0x1, ...}, ...})
C:/dev/src/teleirc/internal/handlers/irc/handlers.go:105 +0x124
github.com/lrstanley/girc.HandlerFunc.Execute(0xe665e9?, 0xc000305e00?, {0x0, 0x0, {0x0, 0x0, 0x0}, {0x11eae0f, 0x13}, {0xc000289260, ...}, ...})
C:/Users/biger/go/pkg/mod/github.com/lrstanley/girc@v0.0.0-20190801035559-4fc93959e1a7/handler.go:67 +0x43
github.com/lrstanley/girc.(*Caller).exec.func1(0x0)
C:/Users/biger/go/pkg/mod/github.com/lrstanley/girc@v0.0.0-20190801035559-4fc93959e1a7/handler.go:231 +0x3d8
created by github.com/lrstanley/girc.(*Caller).exec in goroutine 8
C:/Users/biger/go/pkg/mod/github.com/lrstanley/girc@v0.0.0-20190801035559-4fc93959e1a7/handler.go:209 +0x61b

@BigErn77 BigErn77 added bug Something isn't working needs triage Metadata needs to be triaged and updated labels Feb 5, 2025
@Tjzabel
Copy link
Member

Tjzabel commented Feb 6, 2025

@BigErn77 does TeleIRC consistently fail when a message is being sent over? Normally the only time we see the panic: runtime error message is when there's an invalid .env file. However, that would crash TeleIRC out immediately, not delayed like you're saying.

Is this error reproducible for you, or does it seem to happen at random times? Try running TeleIRC with:

$ ./teleirc -debug=true

@BigErn77
Copy link
Author

BigErn77 commented Feb 6, 2025

@Tjzabel Well I just ran teleirc with the debug switch and got the error immediately:

biger@aceraspireone MINGW64 /c/dev/src/teleirc (main)
$ ./teleirc -debug=true
INFO: 2025/02/05 21:30:04 Current TeleIRC version: v2.3.0-10-g0af3dfe
DEBUG: 2025/02/05 21:30:04 Debug mode enabled!
INFO: 2025/02/05 21:30:04 Creating new Telegram bot client...
INFO: 2025/02/05 21:30:04 Creating new IRC bot client...
INFO: 2025/02/05 21:30:04 Starting up Telegram bot...
INFO: 2025/02/05 21:30:04 Starting up IRC bot...
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: JOIN
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: NICK
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: TOPIC
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: CLIENT_DISCONNECTED
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: KICK
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: PRIVMSG
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: PART
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: QUIT
DEBUG: 2025/02/05 21:30:04 Adding IRC event handler: CLIENT_CONNECTED
INFO: 2025/02/05 21:30:05 Authorized on account TeleIRC2Bot
ERROR: 2025/02/05 21:30:05 Missing message data
DEBUG: 2025/02/05 21:30:05 messageHandler triggered
DEBUG: 2025/02/05 21:30:05 messageHandler triggered
DEBUG: 2025/02/05 21:30:05 messageHandler triggered
DEBUG: 2025/02/05 21:30:05 messageHandler triggered
DEBUG: 2025/02/05 21:30:07 messageHandler triggered
DEBUG: 2025/02/05 21:30:09 messageHandler triggered
DEBUG: 2025/02/05 21:30:11 messageHandler triggered
DEBUG: 2025/02/05 21:30:13 messageHandler triggered
ERROR: 2025/02/05 21:30:21 Missing message data
DEBUG: 2025/02/05 21:30:21 photoHandler triggered
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x80 pc=0xdab512]

goroutine 7 [running]:
github.com/ritlug/teleirc/internal/handlers/telegram.getImgurLink(0xc0002b10c0, {0xc00000e2a0, 0x63})
C:/dev/src/teleirc/internal/handlers/telegram/imgur.go:101 +0x8d2
github.com/ritlug/teleirc/internal/handlers/telegram.uploadImage(0xc0002b10c0, {0x15f7b23, 0xc00047cc80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
C:/dev/src/teleirc/internal/handlers/telegram/helpers.go:68 +0x137
github.com/ritlug/teleirc/internal/handlers/telegram.photoHandler(0xc0002b10c0, {0x15f7b23, 0xc00047cc80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
C:/dev/src/teleirc/internal/handlers/telegram/handler.go:162 +0x58
github.com/ritlug/teleirc/internal/handlers/telegram.updateHandler(0xc0002b10c0, 0xc0000caa10)
C:/dev/src/teleirc/internal/handlers/telegram/handler.go:45 +0x2ca
github.com/ritlug/teleirc/internal/handlers/telegram.(*Client).StartBot(0xc0002b10c0, 0xc00000e620, 0xc0002b1100)
C:/dev/src/teleirc/internal/handlers/telegram/telegram.go:78 +0x387
created by main.main in goroutine 1
C:/dev/src/teleirc/cmd/teleirc.go:53 +0x666

biger@aceraspireone MINGW64 /c/dev/src/teleirc (main)
$

Usually what happens at this point, is I just run it again and it works without crashing. For an hour or so, then it crashes.

@Tjzabel
Copy link
Member

Tjzabel commented Feb 6, 2025

@BigErn77 It looks like IRC is hooking up just fine with all the handlers being properly registered. For more information, are there messages being sent to kick off those messageHandlers? The photo handler was also triggered.

I don't see a connectHandler, nor a joinHandler. This is possibly still pointing towards a potential misconfig. Have you tried connecting your bridge to a fresh (similarly configured) IRC channel, and TG group?

The two stack traces you posted are not consistent, making this a little more difficult to debug. The first errors out trying to create a Telegram message, while the second one crashes on grabbing the imgur link from the photo handler, both Telegram related.

Double check everything you need configured is set up properly: https://docs.teleirc.com/en/latest/user/config-file-glossary/

@Tjzabel
Copy link
Member

Tjzabel commented Feb 6, 2025

For example, here are the beginning logs from our TeleIRC bridge running on our Telegram group, and respective IRC channel:

INFO: 2025/02/05 22:37:08 Current TeleIRC version: v2.3.0-5-g40a9c2c
DEBUG: 2025/02/05 22:37:08 Debug mode enabled!
INFO: 2025/02/05 22:37:08 Creating new Telegram bot client...
INFO: 2025/02/05 22:37:08 Creating new IRC bot client...
INFO: 2025/02/05 22:37:08 Starting up IRC bot...
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: CLIENT_CONNECTED
INFO: 2025/02/05 22:37:08 Starting up Telegram bot...
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: JOIN
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: PRIVMSG
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: TOPIC
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: QUIT
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: CLIENT_DISCONNECTED
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: KICK
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: NICK
DEBUG: 2025/02/05 22:37:08 Adding IRC event handler: PART
INFO: 2025/02/05 22:37:09 Authorized on account Teleirctestbot
DEBUG: 2025/02/05 22:37:17 connectHandler triggered
DEBUG: 2025/02/05 22:37:21 joinHandler triggered
DEBUG: 2025/02/05 22:37:32 messageHandler triggered

@BigErn77
Copy link
Author

BigErn77 commented Feb 6, 2025

Right after I got the error I posted, I immediately ran it again and got the exact same error. Then I immediately ran it again and it works, as is typical in my experience, and I see the connectHandler and joinHandler and messageHandler in the log:

$ ./teleirc -debug=true
INFO: 2025/02/06 04:07:17 Current TeleIRC version: v2.3.0-10-g0af3dfe
DEBUG: 2025/02/06 04:07:17 Debug mode enabled!
INFO: 2025/02/06 04:07:17 Creating new Telegram bot client...
INFO: 2025/02/06 04:07:17 Creating new IRC bot client...
INFO: 2025/02/06 04:07:17 Starting up Telegram bot...
INFO: 2025/02/06 04:07:17 Starting up IRC bot...
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: PRIVMSG
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: PART
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: TOPIC
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: QUIT
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: CLIENT_CONNECTED
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: JOIN
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: KICK
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: NICK
DEBUG: 2025/02/06 04:07:17 Adding IRC event handler: CLIENT_DISCONNECTED
INFO: 2025/02/06 04:07:18 Authorized on account TeleIRC2Bot
DEBUG: 2025/02/06 04:07:57 connectHandler triggered
DEBUG: 2025/02/06 04:07:57 joinHandler triggered
DEBUG: 2025/02/06 04:10:28 messageHandler triggered

Is there a way to catch the error and log it, rather than failing to the command line?

@BigErn77
Copy link
Author

BigErn77 commented Feb 7, 2025

I determined that the crash is happening when a message containing a picture is sent in the Telegram group. It crashes on the getImgurLink method.

DEBUG: 2025/02/07 00:00:18 photoHandler triggered
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x80 pc=0xe6b512]

goroutine 20 [running]:
github.com/ritlug/teleirc/internal/handlers/telegram.getImgurLink(0xc00031e540, {0xc0000cdf10, 0x63})
C:/dev/src/teleirc/internal/handlers/telegram/imgur.go:101 +0x8d2
github.com/ritlug/teleirc/internal/handlers/telegram.uploadImage(0xc00031e540, {0x15f7c22, 0xc000404140, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
C:/dev/src/teleirc/internal/handlers/telegram/helpers.go:68 +0x137
github.com/ritlug/teleirc/internal/handlers/telegram.photoHandler(0xc00031e540, {0x15f7c22, 0xc000404140, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
C:/dev/src/teleirc/internal/handlers/telegram/handler.go:162 +0x58
github.com/ritlug/teleirc/internal/handlers/telegram.updateHandler(0xc00031e540, 0xc00019b1f0)
C:/dev/src/teleirc/internal/handlers/telegram/handler.go:45 +0x2ca
github.com/ritlug/teleirc/internal/handlers/telegram.(*Client).StartBot(0xc00031e540, 0xc0000cc2a0, 0xc00031e580)
C:/dev/src/teleirc/internal/handlers/telegram/telegram.go:78 +0x387
created by main.main in goroutine 1
C:/dev/src/teleirc/cmd/teleirc.go:53 +0x666

@BigErn77
Copy link
Author

BigErn77 commented Feb 7, 2025

I added this code snippet just before line 101 in imgur.go, and now it doesn't crash anymore. I do see that message that I'm logging in the logs, so evidently that response data was null, why would that be the case?:

if resp.Data == nil {
	tg.logger.LogError("Imgur response data was null")
	return "";
}

@BigErn77
Copy link
Author

BigErn77 commented Feb 7, 2025

I finally got it to work correctly by creating and using my own Imgur API Client ID. I can only guess that anonymous uploading starting throttling me after so many pic uploads? In any case, the program shouldn't crash when that happens.

@Tjzabel Tjzabel added Telegram Issues relating to Telegram bridge and removed needs triage Metadata needs to be triaged and updated labels Feb 7, 2025
@Tjzabel Tjzabel self-assigned this Feb 7, 2025
@Tjzabel Tjzabel added this to the v2.2.1 milestone Feb 7, 2025
@Tjzabel
Copy link
Member

Tjzabel commented Feb 7, 2025

I finally got it to work correctly by creating and using my own Imgur API Client ID. I can only guess that anonymous uploading starting throttling me after so many pic uploads? In any case, the program shouldn't crash when that happens.

Great! Yes the anonymous imgur API will throttle, which is why we recommend generating your own client ID. I appreciate your patience in debugging! I will add more error handling around checking the response to ensure crashes don't happen in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Telegram Issues relating to Telegram bridge
Projects
None yet
Development

No branches or pull requests

2 participants