d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
524 stars 40 forks source link

`tdlib` database making `nchat` crash when highlighting problematic chat #175

Closed Kabouik closed 6 months ago

Kabouik commented 6 months ago

Description: Someone sent me a ~25-30MB video and I could download it just fine in nchat with C-r, but then after I closed it, it would crash upon re-opening all the time, and immediately. I unfortunately have no logs (but I have td.log if that can be useful).

How to reproduce it: I tried deleting nchat's database but that did not help. I also tried deleting tdlib's database and the issue persisted, but I had the impression that it would take a split second more before it crash (still immediate, I was not even sure there was a difference).

I logged in Telegram desktop, deleted the video I received, quit. nchat would still crash on launch. Deleted the tdlib sqlite files, and then nchat runs normally. Somehow, that video, which is just a regular video recorded on a phone, made the whole thing crash while it worked fine on Telegram desktop, and also worked fine the first time in nchat.

Not sure if the issue is with nchat or tdlib.

I can share the video file if that is relevant. I have not tried to reproduce the bug by asking the contact to send it again.

Environment:

d99kris commented 6 months ago

Hi @Kabouik - thanks for reporting a bug. I tried receiving a 30 MB video clip just now, and I don't see any issues. Yes, if you could share the video file it would be great, in case it's somehow related to the file/type. Perhaps via Telegram is easiest.

Btw, is there any chance your system might've been low on storage space when you encountered the issue?

Edit: Yes, if you still have the td.log file, please share it as well. It might give some hint.

Kabouik commented 6 months ago

I am having the issue with another chat, a group chat this time. It is quite active so I am not sure which message is the cause, but you could try to join in, see if you can replicate. It happens regardless of the attachment_prefetch setting, even after I delete both nchat and tdlib databases (so I couldn't identify which one might be responsible for the crash), whenever I pass over that chat (even without selecting the message), and even after deleting the tdlib database.

I tried getting the logs with -ee this time, but only got this log.txt:

2023-12-28 07:56:47.809 | INFO  | starting nchat v4.21  (main.cpp:239)
2023-12-28 07:56:47.821 | INFO  | entering ui loop  (ui.cpp:95)

And this td.log:

[ 0][t 0][1703746738.805336475][MessageEntity.cpp:2515] Check `is_continuous_entity(entity.type)` failed`

I can send you the video and link to the other group tomorrow, they're on a different device (I don't have telegram-desktop on this one so getting the group URL won't be trivial).

I'm not low on space or RAM on that system. I am on v4.21 on this machine and the problematic chat doesn't seem to make 4.13 crash on my second machine (aarch64), despite the same configuration files. However, I am pretty sure both crashed on the video file that made me open this issue (I even reported so).

Kabouik commented 6 months ago

Could this be related to a bad connection (if so, I would assume that attachment_prefetch would have an effect on the crash occurrence)?

The said chat does not crash my nchat instance anymore, even if I go back many messages in the backlog (the chat has been active since my message last night). Yet, the crash was very consistent and reproducible last night, and nothing changed on my system. I didn't even reboot. But my connection was pretty bad yesterday; it still is, but not that bad.

d99kris commented 6 months ago

Hi @Kabouik - thanks for sharing additional details. I'm not sure what could be the cause at this point.

Btw, there was another crash issue reported yesterday #177 which could have same root cause as the crashes you were seeing. In case you were seeing core dumped after nchat crashed, and you have coredumpctl and gdb available, you could try obtain the crash callstack using the steps in https://github.com/d99kris/nchat/issues/177#issuecomment-1871692473

Kabouik commented 6 months ago

No, this is all I get:

fish: Job 1, 'nchat -d /home/droidian/.config…' terminated by signal SIGABRT (Abort)
d99kris commented 6 months ago

The crash in #177 has been fixed in b4d1fa5. It affected markdown conversion when receiving messages with certain formatting. It's possible such message existed in your chat and that the message was later deleted or edited to not have this particular formatting, so the issue went away.

Since you're not seeing the crash anymore, I will proceed to close this issue. If you see it again, please try latest nchat (v4.23 or later) and feel free to re-open this issue if the crash is still observed there.