SN-10156 附来源、原文与上下文。
我把它放在 bitcoin.org/download/linux64-0.2.7.1.tar.gz。你拿到后可以删掉。
I put it at bitcoin.org/download/linux64-0.2.7.1.tar.gz. You can delete it when you've got it.
我考虑了什么可能导致你遇到的问题,并作了一处修改,包含在这个构建中。这段代码可能不安全,尽管大概总能侥幸运行。
I thought about what might cause the problem you're having and made a change that this build includes. This might have been unsafe code, although it would probably always get lucky.
util.cpp 中的旧代码:
in util.cpp, old:
const char* wxGetTranslation(const char* pszEnglish)
{
// Wrapper of wxGetTranslation returning the same const char* type
// as was passed in
static CCriticalSection cs;
CRITICAL_BLOCK(cs)
{
// Look in cache
static map<string, char*> mapCache;
map<string, char*>::iterator mi = mapCache.find(pszEnglish);
if (mi != mapCache.end())
return (*mi).second;
// wxWidgets translation
const char* pszTranslated =
wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str();
// We don't cache unknown strings because caller might be
// passing in a dynamic string and we would keep allocating
// memory for each variation.
if (strcmp(pszEnglish, pszTranslated) == 0)
return pszEnglish;
// Add to cache, memory doesn't need to be freed. We only
// cache because we must pass back a pointer to permanently
// allocated memory.
char* pszCached = new char[strlen(pszTranslated)+1];
strcpy(pszCached, pszTranslated);
mapCache[pszEnglish] = pszCached;
return pszCached;
}
return NULL;
}
const char* wxGetTranslation(const char* pszEnglish)
{
// Wrapper of wxGetTranslation returning the same const char* type
// as was passed in
static CCriticalSection cs;
CRITICAL_BLOCK(cs)
{
// Look in cache
static map<string, char*> mapCache;
map<string, char*>::iterator mi = mapCache.find(pszEnglish);
if (mi != mapCache.end())
return (*mi).second;
// wxWidgets translation
const char* pszTranslated =
wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str();
// We don't cache unknown strings because caller might be
// passing in a dynamic string and we would keep allocating
// memory for each variation.
if (strcmp(pszEnglish, pszTranslated) == 0)
return pszEnglish;
// Add to cache, memory doesn't need to be freed. We only
// cache because we must pass back a pointer to permanently
// allocated memory.
char* pszCached = new char[strlen(pszTranslated)+1];
strcpy(pszCached, pszTranslated);
mapCache[pszEnglish] = pszCached;
return pszCached;
}
return NULL;
}
新代码:
new:
const char* wxGetTranslation(const char* pszEnglish)
{
// Wrapper of wxGetTranslation returning the same const char* type
// as was passed in
static CCriticalSection cs;
CRITICAL_BLOCK(cs)
{
// Look in cache
static map<string, char*> mapCache;
map<string, char*>::iterator mi = mapCache.find(pszEnglish);
if (mi != mapCache.end())
return (*mi).second;
// wxWidgets translation
wxString strTranslated = wxGetTranslation(wxString(pszEnglish,
wxConvUTF8));
// We don't cache unknown strings because caller might be
// passing in a dynamic string and we would keep allocating
// memory for each variation.
if (strcmp(pszEnglish, strTranslated.utf8_str()) == 0)
return pszEnglish;
// Add to cache, memory doesn't need to be freed. We only
// cache because we must pass back a pointer to permanently
// allocated memory.
char* pszCached = new char[strlen(strTranslated.utf8_str())+1];
strcpy(pszCached, strTranslated.utf8_str());
mapCache[pszEnglish] = pszCached;
return pszCached;
}
return NULL;
}
const char* wxGetTranslation(const char* pszEnglish)
{
// Wrapper of wxGetTranslation returning the same const char* type
// as was passed in
static CCriticalSection cs;
CRITICAL_BLOCK(cs)
{
// Look in cache
static map<string, char*> mapCache;
map<string, char*>::iterator mi = mapCache.find(pszEnglish);
if (mi != mapCache.end())
return (*mi).second;
// wxWidgets translation
wxString strTranslated = wxGetTranslation(wxString(pszEnglish,
wxConvUTF8));
// We don't cache unknown strings because caller might be
// passing in a dynamic string and we would keep allocating
// memory for each variation.
if (strcmp(pszEnglish, strTranslated.utf8_str()) == 0)
return pszEnglish;
// Add to cache, memory doesn't need to be freed. We only
// cache because we must pass back a pointer to permanently
// allocated memory.
char* pszCached = new char[strlen(strTranslated.utf8_str())+1];
strcpy(pszCached, strTranslated.utf8_str());
mapCache[pszEnglish] = pszCached;
return pszCached;
}
return NULL;
}
如果你仍然怀疑这段代码,测试时可以把它改为:
If you still suspect this code, for testing you could change it to:
const char* wxGetTranslation(const char* pszEnglish)
{
return pszEnglish;
}
const char* wxGetTranslation(const char* pszEnglish)
{
return pszEnglish;
}
引用 Martti Malmi 的文字Martti Malmi来源 ↗我试着用 ddd 调试器调试自己构建的 bitcoind,但还没怎么成功。它总是占用系统的全部内存,最后崩溃。能请你再发我一次最新的 64 位 bitcoind 构建吗?这样我就能看看,问题是否出在我自己的构建。
I tried debugging my build of bitcoind with ddd debugger, but didn't have much success yet. It always ends up taking all the system's memory and finally crashes. Could you please send me again the latest 64 bit build of bitcoind, so I can see if the problem is about my build?