aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-11-18 11:58:32 +0100
committerLuke Dashjr <luke-jr+git@utopios.org>2012-11-22 19:45:03 +0000
commit0d989a99d045d692695d6890b37ccb679f03c6ba (patch)
treed4f552bc6ed3e7e719204b8b43cecfd046089fef
parentcb44c07349175514c608a115ec3bf92c23296e19 (diff)
downloadbitcoin-0d989a99d045d692695d6890b37ccb679f03c6ba.tar.xz
Bitcoin-Qt: fix crash on Windows caused by CDBEnv::EnvShutdown()
- can be triggerd by just adding -proxy=crashme with 0.7.1 - crash occured, when AppInit2() was left with return false; after the first call to bitdb.open() (Step 6 in init) - this is caused by GetDataDir() or .string() in CDBEnv::EnvShutdown() called via the bitdb global destructor - init fDbEnvInit and fMockDb to false in CDBEnv::CDBEnv()
-rw-r--r--src/db.cpp7
-rw-r--r--src/db.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 297240c842..21c3da4cda 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -38,11 +38,13 @@ void CDBEnv::EnvShutdown()
if (ret != 0)
printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret);
if (!fMockDb)
- DbEnv(0).remove(GetDataDir().string().c_str(), 0);
+ DbEnv(0).remove(strPath.c_str(), 0);
}
CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS)
{
+ fDbEnvInit = false;
+ fMockDb = false;
}
CDBEnv::~CDBEnv()
@@ -65,6 +67,7 @@ bool CDBEnv::Open(boost::filesystem::path pathEnv_)
pathEnv = pathEnv_;
filesystem::path pathDataDir = pathEnv;
+ strPath = pathDataDir.string();
filesystem::path pathLogDir = pathDataDir / "database";
filesystem::create_directory(pathLogDir);
filesystem::path pathErrorFile = pathDataDir / "db.log";
@@ -85,7 +88,7 @@ bool CDBEnv::Open(boost::filesystem::path pathEnv_)
dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
- int ret = dbenv.open(pathDataDir.string().c_str(),
+ int ret = dbenv.open(strPath.c_str(),
DB_CREATE |
DB_INIT_LOCK |
DB_INIT_LOG |
diff --git a/src/db.h b/src/db.h
index 798913645f..58e9da31f2 100644
--- a/src/db.h
+++ b/src/db.h
@@ -37,6 +37,7 @@ private:
bool fDbEnvInit;
bool fMockDb;
boost::filesystem::path pathEnv;
+ std::string strPath;
void EnvShutdown();