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

Failure in Telegram setup results in RAM leak #272

Closed
Lympri opened this issue Aug 5, 2024 · 6 comments
Closed

Failure in Telegram setup results in RAM leak #272

Lympri opened this issue Aug 5, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Lympri
Copy link

Lympri commented Aug 5, 2024

Description:
If you try and fail to configure Telegram access and just leave it there, nchat starts in loop trying to login again and again:

"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.862 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.863 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}
"  (tgchat.cpp:2216)
2024-08-05 21:10:06.863 | WARN  | auth error "error {
  code = 401
  message = "Wrong database encryption key"
}

This will go on so long that machine either totally freezes or puts out OOM error and forekills nchat.

How to reproduce it:
Setup Telegram and fail, don't remove config of it

Environment:

  • Version: nchat v4.86
  • OS / distro: Arch Linux x86_64, 6.10.2-arch1-1

Additional info
I did not test if failure in Whatsapp does same, nor did I test anything else, this just bugged me for half of year and I wish no one else should suffer from this.

@Lympri Lympri added the bug Something isn't working label Aug 5, 2024
@d99kris
Copy link
Owner

d99kris commented Aug 7, 2024

Hi @Lympri - thanks for reporting a bug! Could you share a bit more detailed steps, as I cannot reproduce the problem here. I tried from a clean slate, i.e. using a non-existent nchat config dir, selected Telegram, entered a valid phone number, entered wrong authentication code. Nchat exits directly (i.e. no hang or repeated log entries).

$ nchat -d ~/tmpnchat -e -s
Protocols:
0. Dummy
1. Telegram
2. WhatsAppMd
3. Exit setup
Select protocol (3): 1
Enter phone number (ex. +6511111111): +xxxxxxxxxxxx    (my actual number redacted)
Enter authentication code: 99735
Authentication error: PHONE_CODE_INVALID
Setup failed
$

(I also attempted wrong phone number and wrong password, same results)

Is the above what you did too (wrong authentication code), or something else?

Do you have a single profile, or multiple protocols/profiles set up (like ok WhatsApp + failed Telegram, or other combination)?

Thanks!

@Lympri
Copy link
Author

Lympri commented Aug 8, 2024

(I also attempted wrong phone number and wrong password, same results)

Is the above what you did too (wrong authentication code), or something else?

I cannot login to telegram as it says that I need to update telegram. My telegram-cli should be at newest version

$ pacman -Q --info telegram-cli
Name            : telegram-cli-git
Version         : r1365.7f8f739-1

Do you have a single profile, or multiple protocols/profiles set up (like ok WhatsApp + failed Telegram, or other combination)?

I am not quite sure, I had in profiles folder 2 directories, 1 for WhatsApp (working, but I didn't use it because using it ate all ram)

@Lympri
Copy link
Author

Lympri commented Aug 8, 2024

(I also attempted wrong phone number and wrong password, same results)

Is the above what you did too (wrong authentication code), or something else?

I cannot login to telegram as it says that I need to update telegram. My telegram-cli should be at newest version

$ pacman -Q --info telegram-cli
Name            : telegram-cli-git
Version         : r1365.7f8f739-1

Do you have a single profile, or multiple protocols/profiles set up (like ok WhatsApp + failed Telegram, or other combination)?

I am not quite sure, I had in profiles folder 2 directories, 1 for WhatsApp (working, but I didn't use it because using it ate all ram) and another for Telegram (but it's removed allready).

After that removal WhatsApp has worked like a charm.

@d99kris
Copy link
Owner

d99kris commented Aug 9, 2024

I cannot login to telegram as it says that I need to update telegram.

Could you share the error message? The telegram service maintains support for old clients pretty long, so you would need a very old version of nchat to run into that, should definitely not happen in v4.86.

My telegram-cli should be at newest version

nchat does not use telegram-cli. nchat has its telegram client code bundled / built-in.

I am not quite sure, I had in profiles folder 2 directories, 1 for WhatsApp (working, but I didn't use it because using it ate all ram) and another for Telegram (but it's removed allready).

Thanks, this is useful! I will try this scenario.

@d99kris
Copy link
Owner

d99kris commented Aug 9, 2024

Was able to reproduce repeated "Wrong database encryption key" log entries now, although in a bit hacky way:

  1. Set up telegram successfully, exit nchat
  2. Remove line starting with local_key= from nchat/profiles/Telegram_+nnnnnnnn/telegram.conf
  3. Start nchat again

Will prepare a fix which avoids the infinite loop in this scenario. I'm still not sure how one can end up in this situation (without manually editing/removing telegram.conf) but will do this fix for now.

@d99kris
Copy link
Owner

d99kris commented Aug 10, 2024

The high CPU usage and memory leak on broken Telegram setup should be addressed in above commit. Please let me know if still encountered.

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

No branches or pull requests

2 participants