Mrs4s / MiraiGo

qq协议的golang实现, 移植于mirai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

新版本使用FetchQRCode()登录时出现空指针错误

MatchaC opened this issue · comments

原版本FetchQRCode()可以正常使用
代码未修改,仅把依赖更新成最新版v0.0.0-20230605125224-758c7b8efa40
报错如下

=== RUN TestLogin
--- FAIL: TestLogin (0.29s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x9fc5e1]

goroutine 6 [running]:
testing.tRunner.func1.2({0xb18280, 0xf4aac0})
C:/Go/1.20.4/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
C:/Go/1.20.4/src/testing/testing.go:1529 +0x39f
panic({0xb18280, 0xf4aac0})
C:/Go/1.20.4/src/runtime/panic.go:884 +0x213
github.com/Mrs4s/MiraiGo/client/internal/network.(*Transport).packBody(0xc000008420, 0xc000075d68, 0xc00050c6f0)
D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/internal/network/transport.go:53 +0x3e1
github.com/Mrs4s/MiraiGo/client/internal/network.(*Transport).PackPacket(0xc000008420, 0xc000075d68)
D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/internal/network/transport.go:127 +0x28f
github.com/Mrs4s/MiraiGo/client.(*QQClient).buildQRCodeFetchRequestPacket(0xc000158c00, 0x3, 0x4, 0x2)
D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/builders.go:190 +0x18c
github.com/Mrs4s/MiraiGo/client.(*QQClient).FetchQRCodeCustomSize(0xc000158c00, 0x294510?, 0xc0?, 0xc7d360?)
D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/client.go:302 +0x5f
github.com/Mrs4s/MiraiGo/client.(*QQClient).FetchQRCode(...)
D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/client.go:291
github.com/MatchaC/mcc/client.(*QQClient).Login(0xc00029e050, 0xc0002ac0a0)
D:/Project/Go/src/mcc/client/qq.go:53 +0xac
github.com/MatchaC/mcc.(*Engine).Run(0xc0002ac0a0)
D:/Project/Go/src/mcc/engine.go:101 +0x42
github.com/MatchaC/mcc/test.TestLogin(0x0?)
D:/Project/Go/src/mcc/test/login_test.go:11 +0x65
testing.tRunner(0xc000051860, 0xbf69a8)
C:/Go/1.20.4/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
C:/Go/1.20.4/src/testing/testing.go:1629 +0x3ea

经测试
MiraiGo-Template使用的v0.0.0-20230319092203-62d60f132203
go-cqhttp使用的v0.0.0-20230401072048-f8d9841755b5
均没有问题,问题出在更新的版本上

commented

原版本FetchQRCode()可以正常使用 代码未修改,仅把依赖更新成最新版v0.0.0-20230605125224-758c7b8efa40 报错如下

=== RUN TestLogin --- FAIL: TestLogin (0.29s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x9fc5e1]

goroutine 6 [running]: testing.tRunner.func1.2({0xb18280, 0xf4aac0}) C:/Go/1.20.4/src/testing/testing.go:1526 +0x24e testing.tRunner.func1() C:/Go/1.20.4/src/testing/testing.go:1529 +0x39f panic({0xb18280, 0xf4aac0}) C:/Go/1.20.4/src/runtime/panic.go:884 +0x213 github.com/Mrs4s/MiraiGo/client/internal/network.(*Transport).packBody(0xc000008420, 0xc000075d68, 0xc00050c6f0) D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/internal/network/transport.go:53 +0x3e1 github.com/Mrs4s/MiraiGo/client/internal/network.(*Transport).PackPacket(0xc000008420, 0xc000075d68) D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/internal/network/transport.go:127 +0x28f github.com/Mrs4s/MiraiGo/client.(*QQClient).buildQRCodeFetchRequestPacket(0xc000158c00, 0x3, 0x4, 0x2) D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/builders.go:190 +0x18c github.com/Mrs4s/MiraiGo/client.(*QQClient).FetchQRCodeCustomSize(0xc000158c00, 0x294510?, 0xc0?, 0xc7d360?) D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/client.go:302 +0x5f github.com/Mrs4s/MiraiGo/client.(*QQClient).FetchQRCode(...) D:/Project/Go/pkg/mod/github.com/!mrs4s/!mirai!go@v0.0.0-20230605125224-758c7b8efa40/client/client.go:291 github.com/MatchaC/mcc/client.(*QQClient).Login(0xc00029e050, 0xc0002ac0a0) D:/Project/Go/src/mcc/client/qq.go:53 +0xac github.com/MatchaC/mcc.(*Engine).Run(0xc0002ac0a0) D:/Project/Go/src/mcc/engine.go:101 +0x42 github.com/MatchaC/mcc/test.TestLogin(0x0?) D:/Project/Go/src/mcc/test/login_test.go:11 +0x65 testing.tRunner(0xc000051860, 0xbf69a8) C:/Go/1.20.4/src/testing/testing.go:1576 +0x10b created by testing.(*T).Run C:/Go/1.20.4/src/testing/testing.go:1629 +0x3ea

经测试 MiraiGo-Template使用的v0.0.0-20230319092203-62d60f132203 go-cqhttp使用的v0.0.0-20230401072048-f8d9841755b5 均没有问题,问题出在更新的版本上

wrapper.AllowSignSendMsg() 导致的,去掉 wrapper.AllowSignSendMsg() && 可以解决报错

commented

@6DDUU6 https://github.com/Mrs4s/MiraiGo/blob/master/wrapper/codec.go#L7 missing function body

不好意思忘记加nil判断了,我去pr一下

#337 经测试该版本已修复