lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
980 stars 388 forks source link

Run in large amounts of data for a long time,An error occurred In the function "__int8_t_encode_array()" #362

Open QiTianDaShengDaShi opened 2 years ago

QiTianDaShengDaShi commented 2 years ago

Run in large amounts of data for a long time,An error occurred In the function "__int8_t_encode_array()"

in lcm/lcm_coretypes.h ,An error occurred In the function "__int8_t_encode_array()" `static inline int __int8_t_encode_array(void _buf, int offset, int maxlen, const int8_t p, int elements) { if (maxlen < elements)//最终定位到出问题的点 return -1;

int8_t *buf = (int8_t *) _buf;
memcpy(&buf[offset], p, elements);//从存储区 p 复制 elements 个字节到存储区 &buf[offset] 。

return elements;

}`

There is a problem here if (maxlen < elements) return -1;

在长时间的运行后,并且传输的数据量时大时小,最后在这里出现了错误,返回了-1,导致我的程序奔溃,我找了很久没有找到原因,大家有遇到过找个问题嘛? 我看了一下代码,maxlen 应该是从函数 `//获取大小 static inline int __string_encoded_array_size(char const s, int elements) { int size = 0; int element; for (element = 0; element < elements; element++) size += 4 + strlen(s[element]) + 1;

return size;

} ` 这里获取的。

大家有遇到过找个问题嘛?