Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua-seri bug #28

Closed
lparam opened this issue Aug 9, 2013 · 2 comments
Closed

lua-seri bug #28

lparam opened this issue Aug 9, 2013 · 2 comments

Comments

@lparam
Copy link

lparam commented Aug 9, 2013

把config里的harbor设置为大于127之后,程序在执行到main.lua中 skynet.monitor "simplemonitor"的时候会挂起,跟踪后发现是lua-seri 模块对unsigned integer类型处理不正确引起的:
lua-seri.c:337
case LUA_TNUMBER: {
lua_Integer x = lua_tointeger(L,index);
lua_Number n = lua_tonumber(L,index);
if ((lua_Number)x==n) {
wb_integer(b, x, TYPE_NUMBER);
} else {
wb_number(b,n);
}
lua_integer被定义为ptrdiff_t(在64位机器上为 long int),在类型转换后x==n会成立,从而把unsigned integer当成signed integer处理。

patch:
lua_Integer x = lua_tointeger(L,index); -> int32_t x = (int32_t)lua_tointeger(L,index);

@cloudwu
Copy link
Owner

cloudwu commented Aug 10, 2013

谢谢, 一并修改了另一个类似的地方.

@cloudwu cloudwu closed this as completed Aug 10, 2013
@cloudwu
Copy link
Owner

cloudwu commented Aug 10, 2013

这个 bug 在 https://github.com/cloudwu/lua-serialize 这个子项目中, 三月的时候就修复了. 一直没有合并到这里来 ><

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants