Skip to content

fix: double free - #156

Closed
ushen-pyj wants to merge 2 commits into
cloudwu:masterfrom
ushen-pyj:master
Closed

ushen-pyj wants to merge 2 commits into
cloudwu:masterfrom
ushen-pyj:master

Conversation

@ushen-pyj

Copy link
Copy Markdown
Contributor
stack traceback:
        [C]: in function 'ltask.unpack_remove'
        lualib/service.lua:916: in upvalue 'schedule_message'
        lualib/service.lua:932: in local 'mainloop'
        lualib/service.lua:941: in main chunk
double free or corruption (fasttop)```

原因在于, table.move 不会截断尾部,消息重复

@cloudwu

cloudwu commented Oct 19, 2026

Copy link
Copy Markdown
Owner

因为 n 是 queue 的原长,这个其实应该写成(此为 lua 处理这种移动的惯用写法):

table.move(queue, i, n+i-1, 1)

这样可以避免在 lua 中引入 for 循环。

@cloudwu cloudwu closed this in 950165e Oct 19, 2026
@ushen-pyj

Copy link
Copy Markdown
Contributor Author

因为 n 是 queue 的原长,这个其实应该写成(此为 lua 处理这种移动的惯用写法):

table.move(queue, i, n+i-1, 1)

这样可以避免在 lua 中引入 for 循环。

又学会一招

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

Successfully merging this pull request may close these issues.

2 participants