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

grpc H2UnsentResponse LeakSanitizer: detected memory leaks #2738

Open
hpsdy opened this issue Aug 19, 2024 · 4 comments
Open

grpc H2UnsentResponse LeakSanitizer: detected memory leaks #2738

hpsdy opened this issue Aug 19, 2024 · 4 comments

Comments

@hpsdy
Copy link

hpsdy commented Aug 19, 2024

Describe the bug (描述bug)
asan 压测,报h2协议brpc::policy::H2UnsentResponse::New内存泄漏

To Reproduce (复现方法)
brpc1.8.0,h2:grpc协议。编译选项加上-fsanitize=address -fno-common,编译静态链接asan。

Expected behavior (期望行为)
期望不报任何异常错误。

Versions (各种版本)
OS: Linux bae12e6ce16f 5.4.139-1.el7.elrepo.x86_64 #1 SMP Sat Aug 7 08:29:46 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
Compiler: clang version 10.0.0-4ubuntu1
brpc: 1.8.0
protobuf: v3.20.0

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

截屏2024-08-19 上午11 38 13 截屏2024-08-19 上午11 38 24
@hpsdy
Copy link
Author

hpsdy commented Aug 26, 2024

有人么?

@chenBright
Copy link
Contributor

H2UnsentResponse::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) {
#if defined(BRPC_PROFILE_H2)
bvar::ScopedTimer<bvar::Adder<int64_t> > tm(g_append_response_time);
#endif
DestroyingPtr<H2UnsentResponse> destroy_self(this);

void H2UnsentResponse::Destroy() {
for (size_t i = 0; i < _size; ++i) {
_list[i].~Header();
}
this->~H2UnsentResponse();
free(this);
}

在Socket里会调AppendAndDestroySelf回收的。

压测场景下,出现内存泄漏,应该不止泄漏几百bytes吧。是不是进程退出的时候,server还在处理请求呢?

@hpsdy
Copy link
Author

hpsdy commented Sep 23, 2024

进程没有退出,mem leak check是开了一个线程定时调用__lsan_do_recoverable_leak_check函数实现检查的。开启后,压测服务,一直会报这个case。不确定是asan检查机制识别不了这种内存释放,还是确实有泄漏。

@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 26, 2024

我记得asan是进程退出时才产出内存泄露报告的,如果进程没退出就检查,可能会不准确吧

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

3 participants