Skip to content

LoadTableHandlers not exception safe #13303

Open
@Ignition

Description

#2  0x000055a53cb70c3a in __cxxabiv1::__terminate(void (*)()) ()
#3  0x000055a53cb70ca5 in std::terminate() ()
#4  0x000055a53c768a81 in std::vector<std::thread, std::allocator<std::thread> >::~vector() ()
#5  0x000055a53c8f3d3a in rocksdb::VersionBuilder::Rep::LoadTableHandlers(rocksdb::InternalStats*, int, bool, bool, std::shared_ptr<rocksdb::SliceTransform const> const&, unsigned long) ()

Relevant code

std::vector<port::Thread> threads;
for (int i = 1; i < max_threads; i++) {
  threads.emplace_back(load_handlers_func);
}
load_handlers_func();
for (auto& t : threads) {
  t.join();
}

As far as I can tell either an exception came from emplace_back or from load_handlers_func. But in either case it caused the std::thread's destructor to have an issue because it wasn't joined yet and hence std::terminate was called.

std::thread::~thread If *this has an associated thread (joinable() == true), std::terminate() is called.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions