堆损坏?Windows在SwiftIndex.exe中触发了断点

时间:2014-03-21 02:07:45

标签: c++ recursion heap-corruption

我知道有类似的问题已被提出,但我仍然无法弄清楚出了什么问题。如上所述,我正在调试VS2010程序,它总是告诉我“这可能是由于堆的损坏,表示SwiftIndex.exe或它加载的任何DLL中的错误......“。所以,这是我的代码的一部分:

Status  PrefixQuickSI::my_QucikSI(std::vector<_QISymbol> &cur_sequence, QISequence        graphcode, int  depth, int feature_size, ECVector<char> cur_UsageTab,     ECVector<SequenceIndex> cur_MappingTab, bool &flag)
{
Status st;
int vcnt = m_QueryGraph->V();
_QISymbol T;
if(depth == 0)                                      
{
    T.tSymbol = graphcode.sequence[depth]->tSymbol; 
    T.rSymbols.clear();
    for(int i = 0; i < graphcode.sequence[depth]->numOfRSymbol; i++)
    {
        int  v1,v2;
        Label elabel;
        v1 = graphcode.sequence[depth]->rSymbol[i].val;
        v2 = graphcode.sequence[depth]->rSymbol[i+1].val;
        elabel = graphcode.sequence[depth]->rSymbol[i].lable;
        if(m_QueryGraph->getELabel(cur_MappingTab[v1],cur_MappingTab[v2]) != elabel)
        {   
            flag = false;
            return OK;
        }
        T.rSymbols.push_back(graphcode.sequence[depth]->rSymbol[i]);
        T.rSymbols.push_back(graphcode.sequence[depth]->rSymbol[i+1]);
        i++;                

    }
    depth++;
    cur_sequence.push_back(T);
    if(depth == graphcode.numOfPrefixNode)
    {
        flag =true;
        return OK;
    }
    else
    {
        st = my_QucikSI(cur_sequence, graphcode,depth, feature_size, cur_UsageTab, cur_MappingTab, flag);
        if(flag == true)
        {
            return OK;
        }
        else
        {
            flag = false;
            return OK;
        }
    }
}
else
{

    T.tSymbol = graphcode.sequence[depth]->tSymbol;  
    for( int j = 0; j < graphcode.sequence[depth]->numOfRSymbol; ++j )  
    {
        RSymbol rSymbol;
        rSymbol = graphcode.sequence[depth]->rSymbol[j];
        T.rSymbols.push_back(rSymbol);
    } 

    int pV;
    VertexIDSet Vcandiates;

    for( int i = 0; i < vcnt; i++ )
    {
        pV = T.tSymbol.p;       
        if( cur_UsageTab[i] > 0 || m_QueryGraph->getLabel(i) != T.tSymbol.l || m_QueryGraph->getELabel(i, cur_MappingTab[pV]) != T.tSymbol.pl)
            continue;

        Vcandiates.insert(i);
    }

    for( VertexIDSet::const_iterator v = Vcandiates.begin(); v != Vcandiates.end(); v++ ) 
    {
        bool mis_match = false;
        for( std::vector<RSymbol>::const_iterator r = T.rSymbols.begin(); r != T.rSymbols.end(); r++ )
        {
            if( !MatchREntry(cur_sequence, *v, *r) )
            {
                mis_match = true;
                break;
            }
        }
        if( mis_match ) 
            continue;
        cur_MappingTab[feature_size + depth] = *v;
        cur_UsageTab[*v] = 1;
        depth++; 
        cur_sequence.push_back(T);
        if(depth == graphcode.numOfPrefixNode)
        {
            flag = true;
            return OK;
        }
        else
        {
            st = my_QucikSI(cur_sequence, graphcode,depth, feature_size, cur_UsageTab, cur_MappingTab,flag);
            if(flag == true)
            {
                return OK;
            }
            else
            {
                cur_UsageTab[*v] = 0;
                depth--;
            }
        }

    }       
}

return OK;
}

并且调用函数语句是:

int depth = 0;
st = my_QucikSI(cur_sequence, datacodes[cur_graphid], depth, cur_size,cur_UsageTab,cur_MappingTab, flag);

我已经逐步调试,发现“堆损坏”发生在函数my_QuickSI的递归的第二次返回中(在第三次递归时,flag已经等于true,并且函数返回到第二次递归,当它即将到来时返回第一次递归,发生“堆腐败”)。 希望有人找到问题所在。

1 个答案:

答案 0 :(得分:0)

您可以找到我之前对您的问题有用的答案:

https://stackoverflow.com/a/22074401/2724703

通常,在您的进程中加载​​的某些DLL /模块已经发生实际损坏之后,通常会检测到堆损坏。