Test case couldn't run: `stop reason = EXC_BAD_ACCESS (code=1, address=0x0)`
- Dominant language
- C++
- Stars
- 39.4k
- Forks
- 8.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I am a newbie of learning levelDB, yet I followed the document to write a test code, it could't run, **the detailed code is:**
```
#include
#include
#include
int main(void)
{
leveldb::DB *db = nullptr;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
assert(status.ok());
std::string key = "A";
std::string value = "a";
std::string get_value;
leveldb::Status s = db->Put(leveldb::WriteOptions(), key, value);
if (s.ok())
s = db->Get(leveldb::ReadOptions(), "A", &get_value);
if (s.ok())
std::cout << get_value << std::endl;
else
std::cout << s.ToString() << std::endl;
delete db;
return 0;
}
```
**And the complie way is:**
```
g++ run_test.cpp -g -o run_test -lpthread -lleveldb -std=c++11
```
**Use lldb to test `Open` method, it will inform that:**
```
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x0000000000000000
frame #1: 0x000000010020d214 libleveldb.1.dylib`leveldb::SanitizeOptions(std::__1::basic_string, std::__1::allocator > const&, leveldb::InternalKeyComparator const*, leveldb::InternalFilterPolicy const*, leveldb::Options const&) + 268
frame #2: 0x000000010020d36c libleveldb.1.dylib`leveldb::DBImpl::DBImpl(leveldb::Options const&, std::__1::basic_string, std::__1::allocator > const&) + 116
frame #3: 0x0000000100211f68 libleveldb.1.dylib`leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string, std::__1::allocator > const&, leveldb::DB**) + 74
frame #4: 0x00000001000028e3 run_test`main at run_test.cpp:10:30
frame #5: 0x00000001000194fe dyld`start + 462
```
What's the probably reason about this situation, and how to solve it? Thanks!
Contributor guide
Research direction
Start with run_test.cpp at the leveldb::DB::Open call on line 10 and reproduce the crash using the shown g++ command and lldb stack trace. Check the linked libleveldb build and compiler/runtime configuration; done means identifying the cause of the EXC_BAD_ACCESS and documenting a reproducible resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100