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

bvar::MultiDimension::delete_stats() may cause core dump #2237

Closed
ketor opened this issue May 6, 2023 · 0 comments
Closed

bvar::MultiDimension::delete_stats() may cause core dump #2237

ketor opened this issue May 6, 2023 · 0 comments

Comments

@ketor
Copy link
Contributor

ketor commented May 6, 2023

Describe the bug (描述bug)
There is a bug in function MultiDimension::delete_stats().
This function use a FlatMap ( MetricMap tmp_map ) and declare a lambda function clear_fn to do clear data in the DoublyBufferedData _metric_map.

But the FlatMap ( MetricMap tmp_map ) is not initialized by init() before use it to do swap().

This will cause segment fault if call get_stats() after delete_stats().

To Reproduce (复现方法)
Implement a new MulitDimension object and call get_stats() in one thread, while another thread do delete_stats() at the same time.
The DoublyBufferedData data structure is thread-safe, but brpc use a wrong method to do delete_stats() which will cause segment fault here.

Expected behavior (期望行为)
No segment fault.

Versions (各种版本)
OS: Ubuntu 22.04/ Rocky 8.x
Compiler:gcc 11
brpc:master
protobuf:3.20.3

Additional context/screenshots (更多上下文/截图)

ketor added a commit to ketor/brpc that referenced this issue May 6, 2023
ketor added a commit to ketor/brpc that referenced this issue May 6, 2023
wwbmmm pushed a commit that referenced this issue May 8, 2023
yanglimingcn pushed a commit to yanglimingcn/brpc that referenced this issue Jun 25, 2023
yanglimingcn pushed a commit to yanglimingcn/brpc that referenced this issue Oct 31, 2023
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