KonataDev / Konata.Core

Android QQ protocol core implementation written in C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug report]引用项目源码,在登录成功接收到消息时抛出异常且无法处理消息

dellbeat opened this issue · comments

Environment / 环境
1.3.1[3dce541]
Windows10 21H2

Event background/ 事件背景
1.首先引用了本工程源码(均为main分支)开始制作机器人软件
2.发现引用源码后一旦机器人接收群信息/好友信息则会抛出异常
3.使用nuget库上的Konata.Core包无异常抛出
4.为确认是否是个人软件编写导致的异常,clone了Kagami项目,并删除nuget包引用,添加项目引用
5.登录Kagami并给BOT发送消息

Expected behavior / 预期行为
1.在有BOT的群内使用/status指令,应显示状态、版本、运行时间等信息

[Kagami]
[branch:main]
[commit:3dce541f972f]
[version:1.3.1]
[Sat, 09 Apr 2022 01:32:25 GMT]

Processed 1 message(s)
GC Memory 14.08 MiB (388.11%)
Total Memory 56.43 MiB

Konata Project (C) 2022

To Reproduce / 复现
参照事件背景第四条第五条即可复现

Stack trace / 堆栈信息
接收消息时抛出的异常

Insufficient buffer space
   在 Konata.Core.Utils.IO.ByteBuffer.TakeBytes(Byte[]& value, UInt32 length) 在 D:\Dev\C#\Konata.Core\Konata.Core\Utils\IO\ByteBuffer.cs 中: 第 682 行

登录成功后概率性抛出的异常

Unable to cast object of type 'Konata.Core.Utils.JceStruct.Model.JNumber' to type 'Konata.Core.Utils.JceStruct.Model.JStruct'.
   at Konata.Core.Packets.SvcPush.SvcPushConfig.<>c.<.ctor>b__8_0(Object userdata, JStruct r) in D:\Dev\C#\Konata.Core\Konata.Core\Packets\SvcPush\SvcPushConfig.cs:line 27
   at Konata.Core.Packets.Wup.UniPacket..ctor(Byte[] payload, UniPacketPayloadReader reader) in D:\Dev\C#\Konata.Core\Konata.Core\Packets\Wup\UniPacket.cs:line 101
   at Konata.Core.Packets.SvcPush.SvcPushConfig..ctor(Byte[] payload) in D:\Dev\C#\Konata.Core\Konata.Core\Packets\SvcPush\SvcPushConfig.cs:line 20
   at Konata.Core.Components.Services.ConfigPushSvc.PushReq.Parse(SSOFrame input, BotKeyStore keystore, PushConfigEvent& output) in D:\Dev\C#\Konata.Core\Konata.Core\Components\Services\ConfigPushSvc\PushReq.cs:line 17
   at Konata.Core.Components.Services.BaseService`1.Parse(SSOFrame input, BotKeyStore keystore, TEvent& output, List`1 extra) in D:\Dev\C#\Konata.Core\Konata.Core\Components\Services\BaseService.cs:line 35
   at Konata.Core.Components.Services.BaseService`1.Konata.Core.Components.Services.IService.Parse(SSOFrame input, BotKeyStore keystore, ProtocolEvent& output, List`1& extra) in D:\Dev\C#\Konata.Core\Konata.Core\Components\Services\BaseService.cs:line 64
   at Konata.Core.Components.PacketComponent.OnIncoming(KonataTask task, PacketEvent packetEvent) in D:\Dev\C#\Konata.Core\Konata.Core\Components\PacketComponent.cs:line 129

請嘗試記錄一下發生 Insufficient buffer space 異常之前的數據包HEX文本, 現在的資訊太少無法定位問題。

另外Unable to cast object of type 'Konata.Core.Utils.JceStruct.Model.JNumber' to type 'Konata.Core.Utils.JceStruct.Model.JStruct'. 異常目前無需擔心, 它不會影響到正常工作

刚回来复现了一下 发送的内容是444 群内发送
数据包HEX文本如下

[recv:OnlinePush.PbPushGroupMsg] 0AD8020A7108C9849BFD0110898FF1A1051852200028A206308B8BA9970638D280B48880808080024A4308BEADA8F401100118C10522270A0A0A0826C3BFC3BF5DC2950A171215E8BF99E6898DE698AFE7B289E889B2E5A5BDE590A71000300238014209626F7448694869486950015801600088010812060801100018001ADA010AD7010A270800108B8BA9970618F6CBCBED0E2000280A300038860140224A0CE5BEAEE8BDAFE99B85E9BB9112070A050A033434341265AA02625002600068009A0159080920CB5078A7C204C80100F00100F80100900200D8028212E002019803D302A0038002B00307B80303C003F09C01D00301E803008A04040801102390048089808004B8048202C00400CA0406081E20013002F8040088051512084A060896807C4001123282012F12270A0A0A0826C3BFC3BF5DC2950A171215E8BF99E6898DE698AFE7B289E889B2E5A5BDE590A71000180220082801109ED4908B011A00

請問一下 Insufficient buffer space 異常的棧日志有打印出來嗎

我重新复现一下带出来看看

重新复现后能拿到的栈日志就这三个

Insufficient buffer space
   在 Konata.Core.Utils.IO.ByteBuffer.TakeBytes(Byte[]& value, UInt32 length) 在 D:\Dev\C#\Konata.Core\Konata.Core\Utils\IO\ByteBuffer.cs 中: 第 682 行
Object reference not set to an instance of an object.
   在 Konata.Core.Utils.Protobuf.ProtoTreeRoot.GetLeafBytes(String leafPath) 在 D:\Dev\C#\Konata.Core\Konata.Core\Utils\Protobuf\ProtoTreeRoot.cs 中: 第 127 行
Object reference not set to an instance of an object.
   在 Konata.Core.Utils.Protobuf.ProtoModel.ProtoLengthDelimited.op_Implicit(ProtoLengthDelimited value) 在 D:\Dev\C#\Konata.Core\Konata.Core\Utils\Protobuf\ProtoModel\ProtoLengthDelimited.cs 中: 第 35 行

解包發現群名片帶有奇怪的字符,
嘗試修改bot的群名片並觀察一下問題能否得到改善。

做过尝试,但是没有改善。
想了解的地方是,源码和release版本是同一个提交哈希的话,代码上应该是没区别的,但是现在却有了未预期行为

[recv:OnlinePush.PbPushGroupMsg]
0A89020A4D08C9849BFD0110898FF1A1051852200028AC0630EA9EAA970638D280888780808080024A1F08BEADA8F401100118C2052203313233300238014209626F7448694869486950015801600088010812060801100018001AAF010AAC010A27080010E89EAA9706189E86E3C3052000280A300038860140224A0CE5BEAEE8BDAFE99B85E9BB9112070A050A03343434125EAA025B5002600068009A0152080920CB5078A7C204C80100F00100F801009002009803D302A0038002B00307B80303C003F09C01D00301E803008A04040801102390048089808004B8048202C00400CA0406081E20013002F80400

Insufficient buffer space
   at Konata.Core.Utils.IO.ByteBuffer.TakeBytes(Byte[]& value, UInt32 length) in D:\Dev\C#\Konata.Core\Konata.Core\Utils\IO\ByteBuffer.cs:line 681

做过尝试,但是没有改善。 想了解的地方是,源码和release版本是同一个提交哈希的话,代码上应该是没区别的,但是现在却有了未预期行为

在main分支上的release提交記錄
3dce541

Y2AN IR_ {WLV~BIUQX65(R

請檢查你的包是否正確

按照现有源码的git提交记录来看提交哈希是一致的 且没有其它改动

image

最近开始重新编写,未复现,暂时关闭issue