Xcode instantly crashes when i build my code 2nd time

325 views Asked by At

I'm coding in C++ in Xcode version 15.0.1 and dealing with memories. When I try to run my code it's fine for the first time, everything behaves as I expected. But when I try to run for the 2nd time, it crashes if I call print_all function in previous run. And it gives this error:

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   Xcode [659]

Application Specific Information:
abort() called

And here is the print_all function:

void print_all(airline *head){
    airline *temp=head;
    while(temp){
        cout<<"\n###################################"<<endl;
        cout<<"### AIRLINE ID: " << temp->ID <<" ###"<<endl;
        cout<<"NAME:"<<temp->name<<endl;
        cout<<"FLIGHTS: ";
        flight *Tempflights= temp->flights;
        while(Tempflights){
            cout<<"#["<<Tempflights->ID<<"|"<<Tempflights->from<<"->"<<Tempflights->to<<"|"<<Tempflights->hour<<":"<<Tempflights->min<<"|"<<Tempflights->price<<"TRY]#";
            Tempflights=Tempflights->next;
        }
        temp=temp->next;
    }
}

This happens in a specific project and specific inputs I give for the first run.

I restarted my Mac and deleted the DerivedData file. I tried to open a new project and the same thing happened.

I logged in App Store Connect.

1

There are 1 answers

0
joeDieBanane On

A buddy of mine experienced a very similar issue in Swift with Xcode. We had run some test and found out that as soon as there are 2 repeat-while loops running in one file of the project then Xcode crashes with the same error as here.

The first build runs pefectly fine but when we try to build the 2nd time it crashes. A workaround is to do a clean build every time, but that is not really a satisfying workflow at all.