Comments (4)
看了相关的代码,并没有发现buf.addSize在处理rn=0的逻辑有问题。你能否提供重现问题的例子呢?
from handy.
@yedf 昨晚找了一下出问题的情况,我这边使用udp-svr/udp-cli进行测试收发,问题在于下面makeRoom和space执行的顺序:
ssize_t rn = recvfrom(fd, buf.makeRoom(kUdpPacketSize), buf.space(), 0, (sockaddr*)&raddr, &rsz);
这样没有问题:
char *pbuf = buf.makeRoom(kUdpPacketSize);
ssize_t rn = recvfrom(fd, pbuf, buf.space(), 0, (sockaddr*)&raddr, &rsz);
深究的话似乎是参数压栈顺序从右向左,而space方法依赖makeRoom,就是先调用space的话返回0
延伸:你那边没有问题吗?并且UDP允许发送0字节的数据,rn=0的话就会出现释放内存错误*** Error in./udp-cli': double free or corruption (top): 0x0000000000f555e0 ***
使用库的makefile编译的:
debian:~$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
from handy.
我原先的代码直接调用space是有问题的,你的修复方式是可行的,已经修复为
ssize_t rn = recvfrom(fd, buf.makeRoom(kUdpPacketSize), kUdpPacketSize, 0, (sockaddr*)&raddr, &rsz);
rn=0导致了buffer在复制时的一个bug,已经修复
谢谢你的issue
from handy.
👍
from handy.
Related Issues (20)
- 学java,你应该需要一款入门服务器
- 关于测试环境 HOT 1
- Question about channel life cycle HOT 1
- 能否加入对Windows IOCP的支持?毕竟Windows下也有一定的需求 HOT 1
- handleHandshake这个的意义 HOT 1
- loop 问题 HOT 5
- 可以实现源IP随机吗? HOT 2
- 能否告知http,post请求的例子 HOT 1
- write会导致崩溃 HOT 1
- 运行报错
- 请问,onRequest 中uri中如何动态加入参数
- HttpServer and EventBase can support multi-thread? HOT 1
- Failed to build handy
- CI doesn't work
- Cmake doesn't build handy_test
- 重启服务端后,客户端显示重连成功,但是服务端并未显示有客户端连上来。 HOT 1
- 作者新开源一个分布式事务管理器github.com/yedf/dtm,欢迎指教 HOT 3
- Logger 的logv 多线程并发访问时可能会导致write失败 HOT 1
- MacOS 编译安装完会影响系统。编译SSL会卡住 HOT 10
- 谁正在用handy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from handy.