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

Assertion failure in CDSAttacher destructor when built with Clang 11 on Linux #6217

Closed
mbautin opened this issue Oct 30, 2020 · 0 comments
Closed
Assignees

Comments

@mbautin
Copy link
Contributor

mbautin commented Oct 30, 2020

(lldb) bt
* thread #1, name = 'kv_table-test', stop reason = hit program assert
    frame #0: 0x00007f2a3b5f8387 libc.so.6`raise + 55
    frame #1: 0x00007f2a3b5f9a78 libc.so.6`abort + 328
    frame #2: 0x00007f2a3b5f11a6 libc.so.6`__assert_fail_base + 294
    frame #3: 0x00007f2a3b5f1252 libc.so.6`__assert_fail + 66
  * frame #4: 0x00007f2a3d962fd7 libyb_util.so`cds::threading::pthread::Manager::detachThread() at pthread_manager.h:179:17
    frame #5: 0x00007f2a3d95c0b9 libyb_util.so`yb::CDSAttacher::~CDSAttacher(this=<unavailable>) at thread.cc:804:3
    frame #6: 0x00007f2a3fa647a6 libserver_process.so`std::__1::default_delete<yb::CDSAttacher>::operator(this=<unavailable>, __ptr=0x000000000d04b820)(yb::CDSAttacher*) const at memory:2262:5
    frame #7: 0x00007f2a3fa6475b libserver_process.so`std::__1::unique_ptr<yb::CDSAttacher, std::__1::default_delete<yb::CDSAttacher> >::reset(this=0x00007f29f86ed6c0, __p=0x0000000000000000) at memory:2517:7
    frame #8: 0x00007f2a3fa5db1b libserver_process.so`std::__1::unique_ptr<yb::CDSAttacher, std::__1::default_delete<yb::CDSAttacher> >::~unique_ptr(this=<unavailable>) at memory:2471:19
    frame #9: 0x00007f2a437a5a77 libc++abi.so.1`__cxxabiv1::(anonymous namespace)::run_dtors(void*) + 71
    frame #10: 0x00007f2a3b998ca2 libpthread.so.0`__nptl_deallocate_tsd + 146
    frame #11: 0x00007f2a3b998eb3 libpthread.so.0`start_thread + 211
    frame #12: 0x00007f2a3b6c08dd libc.so.6`__clone + 109
@mbautin mbautin self-assigned this Oct 30, 2020
mbautin added a commit that referenced this issue Oct 31, 2020
…in Webserver

Summary:
When building the code with Clang 11 on Linux, we get an assertion failure in ~CDSAttacher when it is trying to call cds::threading::Manager::detachThread(). This is because the corresponding thread-local storage inside of libcds's thread-specific data manager has already been destroyed for this thread. The relative order of calls to the "destructor" function passed to pthread_key_create (which is how libcds manages its thread-local storage in pthread_manager.h) and ~CDSAttacher in our webserver.cc file (for a thread managed by the Squeasel web server) is apparently not well defined and depends on the compiler.

The fix is to simply avoid calling cds::threading::Manager::detachThread() for the web server handler threads, as the necessary cleanup will still be done by the "destructor" function of the thread-local storage inside libcds. There is probably some value in calling detachThread() from code that does not belong to a static object's destructor, but it is probably not worth doing that for Squeasel web server's threads just for sanity checking, because that would complicate things unnecessarily.

Test Plan:
Jenkins

Build YugabyteDB with Clang 11 on Linux (we will support that compiler officially soon) and verify that a mini-cluster test such as kv_table-test succeeds.

Reviewers: sergei

Reviewed By: sergei

Subscribers: ybase, bogdan

Differential Revision: https://phabricator.dev.yugabyte.com/D9792
@mbautin mbautin closed this as completed Nov 5, 2020
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

1 participant