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 the first bthread keytable on worker pthread will be deleted twice #1884

Merged
merged 1 commit into from
Aug 15, 2022

Conversation

chenBright
Copy link
Contributor

fix #1714
优雅退出时能只清理pthread创建的keytable,bthread创建的keytable不需要在cleanup_pthread中清理,这些keytable会在return_keytable或者bthread_keytable_pool_destroy中清理。

@chenBright
Copy link
Contributor Author

@zyearn 麻烦有空看一下。

@chenBright
Copy link
Contributor Author

另一方面,是否考虑在退出时,stop and join 一些框架的常驻线程(worker线程、timer线程、bvar相关线程)?因为在退出的时候,全局变量或者静态变量析构后,常驻线程有几率访问到这些变量,存在coredump风险。相关issue:#1594#1726#1634

@tea321000
Copy link

我发现在bthread_keytable_pool_destroy里删除kt之前用atexit_cancel取消kt的回调析构函数似乎也可以防止重复析构

@wwbmmm
Copy link
Contributor

wwbmmm commented Aug 14, 2022

LGTM

@zyearn
Copy link
Member

zyearn commented Aug 14, 2022

另一方面,是否考虑在退出时,stop and join 一些框架的常驻线程(worker线程、timer线程、bvar相关线程)?因为在退出的时候,全局变量或者静态变量析构后,常驻线程有几率访问到这些变量,存在coredump风险。相关issue:#1594#1726#1634

这个问题能否新建一个issue单独讨论? @chenBright

@chenBright
Copy link
Contributor Author

另一方面,是否考虑在退出时,stop and join 一些框架的常驻线程(worker线程、timer线程、bvar相关线程)?因为在退出的时候,全局变量或者静态变量析构后,常驻线程有几率访问到这些变量,存在coredump风险。相关issue:#1594#1726#1634

这个问题能否新建一个issue单独讨论? @chenBright

嗯,已新建issue。麻烦看看这个rp还有没有问题。 @zyearn

@chenBright
Copy link
Contributor Author

我发现在bthread_keytable_pool_destroy里删除kt之前用atexit_cancel取消kt的回调析构函数似乎也可以防止重复析构

先thread_atexit再thread_atexit_cancel,似乎多做了一些无用功,而且直接在开始的时候就不将协程变量对应keytable加入到thread_atexit,应该会直观一点吧。

@jamesge jamesge merged commit a0fc1a2 into apache:master Aug 15, 2022
@chenBright chenBright deleted the fix_double_delete_keytable branch August 15, 2022 03:49
@Huixxi Huixxi added bug the code does not work as expected kind/coredump labels Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug the code does not work as expected kind/coredump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

使用优雅退出时,cleanup_pthread清理keytable会coredump
6 participants