Closed peze closed 7 years ago
大概知道问题在哪儿了
(gdb) f
0 swoole_set_object (object=
, ptr=ptr@entry=0x0) at /data/pkg/swoole-src-1.8.7-stable/swoole.c:421 421 swoole_objects.array[handle] = ptr; (gdb) info f Stack level 0, frame at 0x7fffcfca0880: rip = 0x7f568db2605a in swoole_set_object (/data/pkg/swoole-src-1.8.7-stable/swoole.c:421); saved rip = 0x7f568db3d112 called by frame at 0x7fffcfca0890 source language c. Arglist at 0x7fffcfca0838, args: object=
, ptr=ptr@entry=0x0 Locals at 0x7fffcfca0838, Previous frame's sp is 0x7fffcfca0880 Saved registers: rbx at 0x7fffcfca0848, rbp at 0x7fffcfca0850, r12 at 0x7fffcfca0858, r13 at 0x7fffcfca0860, r14 at 0x7fffcfca0868, r15 at 0x7fffcfca0870, rip at 0x7fffcfca0878 (gdb) info locals handle = 2327694184
这里handle的值已经到23亿了
代码中这段大概有点问题
void swoole_set_object(zval *object, void *ptr)
{
#if PHP_MAJOR_VERSION < 7
zend_object_handle handle = Z_OBJ_HANDLE_P(object);
#else
int handle = (int) Z_OBJ_HANDLE(*object);
#endif
assert(handle < SWOOLE_OBJECT_MAX);
if (handle >= swoole_objects.size)
{
uint32_t old_size = swoole_objects.size;
uint32_t new_size = old_size * 2;
void *old_ptr = swoole_objects.array;
void *new_ptr = NULL;
if (new_size > SWOOLE_OBJECT_MAX)
{
new_size = SWOOLE_OBJECT_MAX;
}
new_ptr = realloc(old_ptr, sizeof(void*) * new_size);
if (!new_ptr)
{
return;
}
bzero(new_ptr + (old_size * sizeof(void*)), (new_size - old_size) * sizeof(void*));
swoole_objects.array = new_ptr;
swoole_objects.size = new_size;
}
swoole_objects.array[handle] = ptr;
}
请升级至最新版本
但是 为何这个handle会变成23亿这么大的数字呢?
对象已被销毁导致的
哦 是我们程序自动销毁导致 还是 swoole内部机制导致的呢?
无法得到更多信息,无法重现,待再次重现后继续跟踪
系统: Linux version 3.12.21-gentoo-r1 (gcc version 4.7.3 (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) ) php: PHP 5.5.18-pl0-gentoo (cli) swoole: swoole-src-1.8.7-stable
下面是通过gdb解析core文件打出的日志:
还望能够解答。谢谢