eBay / Jungle

An embedded key-value store library specialized for building state machine and log store
Apache License 2.0
224 stars 54 forks source link

avoid to close a closed iterator #122

Closed tobecontinued closed 3 years ago

tobecontinued commented 3 years ago

Such code will crash.

StorageEngineJungle::KeyItr::close() {
    if (itr) {
        itr->close();
        DELETE(itr);
    }
    if (snap) {
        DB::close(snap);
        snap = nullptr;
    }
}

27 0x0000563511a97527 in SimpleLoggerMgr::handleSegFault (sig=11) at

28

29 0x0000563511f9202b in jungle::Iterator::close (this=this@entry=0xd856) at

30 0x0000563511f92129 in jungle::Iterator::~Iterator (this=0xd856, __in_chrg=)

greensky00 commented 3 years ago

@tobecontinued Calling Iterator::close() multiple times should be fine because 1) AVL-tree is already empty, and 2) itrs is already cleared. It will simply do nothing. This has been tested (calling close and then once again by the destructor) in many functional test cases. Can you investigate with GDB what caused the crash?

greensky00 commented 3 years ago

Closing this PR as double-closing of iterator has no problem.