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

fix heap overflow in simple_data_pool #1056

Merged
merged 2 commits into from
Mar 8, 2020
Merged

fix heap overflow in simple_data_pool #1056

merged 2 commits into from
Mar 8, 2020

Conversation

yockie
Copy link
Contributor

@yockie yockie commented Mar 6, 2020

1.代码bug:
_capacity初始值为1时,在扩容过程中,由于 1 * 3/2 == 1,所以并没有扩容,而最后的_pool[_size++] = data;并没有再判断size与_capacity的关系,导致堆溢出

2.复现条件:
设置了brpc server option的session_local_data_factory,并且设置reserved_session_local_data为1,client多并发请求时,是必现的。

3.修复方法
_capacity初始值为1时,同_capacity初始值为0一样,强制设为128,而不是通过(_capacity * 3 / 2)计算。

@jamesge jamesge merged commit 6fb40c3 into apache:master Mar 8, 2020
@jamesge
Copy link
Contributor

jamesge commented Mar 8, 2020

Thanks for the fix which is really hard to spot 👍

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.

None yet

2 participants