0

I know that similar question has been asked,but I still can not figure out what is wrong.As mentioned above,I am debugging a program with VS2010 which always telling me "This may be due to a corruption of the heap, which indicates a bug in SwiftIndex.exe or any of the DLLs it has loaded...".So,here is part of my code:

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;
}

and the calling function statement is:

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

I have debugged step by step,and found that the "heap corruption" occurred in the second return of the recursion of function my_QuickSI(flag already equaled true at the third recursion and function returned to the second recursion,when it's about to return to the first recursion,the "heap corruption" happened). Hope someone find where the problem is.

user3162587
  • 233
  • 1
  • 6
  • 18

1 Answers1

0

You can find my previous answer useful for your problem:

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

In general heap corruption is often detected after the real corruption has already occurred by some DLL/module loaded within your process.

Community
  • 1
  • 1
Mantosh Kumar
  • 5,659
  • 3
  • 24
  • 48