Merge pull request #44 from fireice-uk/fix-uninit-access

Make sure all singletons are set to null and make env a global ptr
This commit is contained in:
fireice-uk
2017-10-17 16:55:32 +01:00
committed by GitHub
3 changed files with 20 additions and 25 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ __declspec(dllexport)
#endif
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
{
environment::inst() = env;
environment::inst(&env);
return amd::minethd::thread_starter(threadOffset, pWork);
}
} // extern "C"
+1 -1
View File
@@ -112,7 +112,7 @@ __declspec(dllexport)
#endif
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
{
environment::inst() = env;
environment::inst(&env);
return nvidia::minethd::thread_starter(threadOffset, pWork);
}
} // extern "C"
+18 -23
View File
@@ -12,35 +12,30 @@ struct params;
struct environment
{
static inline environment& inst(environment* init = nullptr)
{
static environment* env = nullptr;
static environment& inst()
{
static environment env;
return env;
}
environment& operator=(const environment& env)
{
this->pPrinter = env.pPrinter;
this->pglobalStates = env.pglobalStates;
this->pJconfConfig = env.pJconfConfig;
this->pExecutor = env.pExecutor;
this->pParams = env.pParams;
return *this;
if(env == nullptr)
{
if(init == nullptr)
env = new environment;
else
env = init;
}
return *env;
}
environment() : pPrinter(nullptr), pglobalStates(nullptr)
environment()
{
}
printer* pPrinter;
globalStates* pglobalStates;
jconf* pJconfConfig;
executor* pExecutor;
params* pParams;
printer* pPrinter = nullptr;
globalStates* pglobalStates = nullptr;
jconf* pJconfConfig = nullptr;
executor* pExecutor = nullptr;
params* pParams = nullptr;
};
} // namepsace xmrstak