3

私は現在、AIプロジェクトに取り組んでいます。最後に並べ替えるには、1 から 8 までの番号が付けられたボードのピースを移動する必要があります (空のスペースには 0 のラベルが付けられます)。しかし、デバッグしようとすると奇妙な問題が発生しました。

int CreateNewState(State *parent, Action action) {
State *newState;

    if (!(newState = (State*)malloc(sizeof(State)))) // <<<< Error
       return 0;
...

   // Populate my newState
   newState->parent = parent;
   newState->matrix = CreateMatrix();
...
   // Insert my newState in the Queue
   Insert(newState, myMode);
}


void Insert(State *state, Mode mode) {
   State *aux;

    if (IsEmpty()) {
        myQueue->firstState = state;
        myQueue->numberOfElements++;
    }
    else {
        aux = myQueue->firstState;

        switch (mode)
        {
            // Breadth First Search
            case BFS:
                while (aux->next != NULL) {
                   aux = aux->next;
                }
                aux->next = state;
                myQueue->numberOfElements++;
                break;
           ...

        }
    }
}

指定されたエラー コメントで、CreateNewState() 関数を 2 回目に呼び出すと、デバッガーが停止してポップアップします。

AIProject_Puzzle.exe がブレークポイントをトリガーしました。

このエラーが発生したときに、コール スタックにいくつかの追加情報を表示しようとしました。

ntdll.dll!RtlReportCriticalFailure()
ntdll.dll!RtlpHeapHandleError()
ntdll.dll!RtlpLogHeapFailure()
ntdll.dll!RtlpAllocateHeap()
ntdll.dll!RtlAllocateHeap()
ucrtbased.dll!00007ff9b582c4da()
ucrtbased.dll!
00007ff9b582c27 .dll!00007ff9b582f34f()
ucrtbased.dll!00007ff9b582fdde()
AIProject_Puzzle.exe!CreateNewState(状態 * 親 = 0x000000c05c273520、アクション アクション = ダウン)

ヒープの破損である可能性があることはわかっているので、これを解決するための手がかりが本当に必要です。Visual Studio Community 2015、VisualC++ を使用しています。このエラーは私を病気にしています。この問題を解決する方法を誰か教えてください。

4

0 に答える 0