RocksDB: Unhandled exception thrown: read access violation

1

I have simple rocksdb program where I create a DB and put some values in it using transactions.

using namespace rocksdb;

std::string kDBPath = "D:\\Newdata";
int main() {
    // open DB
    Options options;
    TransactionDBOptions txn_db_options;
    options.create_if_missing = true;
    TransactionDB* txn_db;

    Status s = TransactionDB::Open(options, txn_db_options, kDBPath, &txn_db);
    assert(s.ok());

    WriteOptions write_options;
    ReadOptions read_options;
    TransactionOptions txn_options;
    std::string value;

    ////////////////////////////////////////////////////////
    //
    // Simple Transaction Example ("Read Committed")
    //
    ////////////////////////////////////////////////////////

    // Start a transaction
    Transaction* txn = txn_db->BeginTransaction(write_options);
    assert(txn);

    // Read a key in this transaction
    //s = txn->Get(read_options, "abc", &value);
    //assert(s.IsNotFound());

    // Write a key in this transaction
    s = txn->Put("abc", "def");
    assert(s.ok());

    // Read a key OUTSIDE this transaction. Does not affect txn.
    s = txn_db->Get(read_options, "abc", &value);
    assert(s.IsNotFound());

    // Write a key OUTSIDE of this transaction.
    // Does not affect txn since this is an unrelated key.
    s = txn_db->Put(write_options, "xyz", "zzz");
    assert(s.ok());

    // Write a key OUTSIDE of this transaction.
    // Fail because the key conflicts with the key written in txn.
    s = txn_db->Put(write_options, "abc", "def");
    assert(s.subcode() == Status::kLockTimeout);

    // Value for key "xyz" has been committed, can be read in txn.
    s = txn->Get(read_options, "xyz", &value);
    assert(s.ok());
    assert(value == "zzz");

    // Commit transaction
    s = txn->Commit();
    assert(s.ok());
    std::cout << "End program";
    return 0;
}

It is failing at first Put. Error:

Exception thrown at 0x00007FF7FCAD0D84 in Rocksdbtest.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Unhandled exception thrown: read access violation.
txn->**** was 0xFFFFFFFFFFFFFF27.

Debugging using VS shows <Unable to read memory> for name field of txn. Same program was running fine before VS update.

c++
visual-studio-2017
windows-10
rocksdb
asked on Stack Overflow Jun 16, 2020 by Kushal Warke • edited Jun 17, 2020 by Kushal Warke

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0