wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
956 stars 156 forks source link

Stack overflow on poison message #246

Closed dmitry-demchuk closed 4 months ago

dmitry-demchuk commented 4 months ago

I've just got a stack overflow exception. Code execution is looping between WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) and WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId)

An example of such "poison message" would be https://t.me/bitrix24_work/858

I'd greatly appreciate if you could look at it.

Exception: Unhandled exception at 0x00007FF6AC1B19CA in App.exe.2232.dmp: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x00000004FB703FF8).

Call stack:

System.Private.CoreLib!System.IO.BinaryReader.InternalRead(int numBytes) Line 472 C# System.Private.CoreLib!System.IO.BinaryReader.ReadUInt32() Line 221 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1407 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# .... WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.TextItalic.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Serialization.ReadTLVector(System.IO.BinaryReader reader) Line 232 C# WTelegramClient!TL.TextConcat.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.PageListItemText.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Serialization.ReadTLVector(System.IO.BinaryReader reader) Line 232 C# WTelegramClient!TL.PageBlockList.ReadTL(System.IO.BinaryReader reader) Line 14 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Serialization.ReadTLVector(System.IO.BinaryReader reader) Line 232 C# WTelegramClient!TL.Page.ReadTL(System.IO.BinaryReader reader) Line 35 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.WebPage.ReadTL(System.IO.BinaryReader reader) Line 142 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.MessageMediaWebPage.ReadTL(System.IO.BinaryReader reader) Line 36 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Message.ReadTL(System.IO.BinaryReader reader) Line 179 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Serialization.ReadTLVector(System.IO.BinaryReader reader) Line 232 C# WTelegramClient!TL.Messages_ChannelMessages.ReadTL(System.IO.BinaryReader reader) Line 55 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!TL.Serialization.ReadTLGzipped(System.IO.BinaryReader reader) Line 401 C# WTelegramClient!TL.Layer.ReadTL(System.IO.BinaryReader reader, uint ctorId) Line 1408 C# WTelegramClient!WTelegram.Client.ReadRpcResult(System.IO.BinaryReader reader) Line 871 C# WTelegramClient!WTelegram.Client.ReadFrame(byte[] data, int dataLen) Line 748 C# WTelegramClient!WTelegram.Client.Reactor(System.IO.Stream stream, System.Threading.CancellationTokenSource cts) Line 486 C# [Resuming Async Method] [External Code] WTelegramClient!WTelegram.Helpers.FullReadAsync(System.IO.Stream stream, byte[] buffer, int length, System.Threading.CancellationToken ct) Line 216 C# [External Code]

wiz0u commented 4 months ago

thanks, will look at it

wiz0u commented 4 months ago

That wasn't a poison message or an infinite recursion problem. Just an abnormal excessive stack usage by .NET with my code.

It should be fixed in 4.0.1-dev.6

dmitry-demchuk commented 4 months ago

You are awesome, as always!

wiz0u commented 4 months ago

consider donating 😉

dmitry-demchuk commented 4 months ago

Will do