Ich erhalte einen Segfault in Windows, aber nicht in Linux (dasselbe Programm). Mit GDB (minGW) bekomme ich folgende Information:Segfault unter Windows, aber nicht unter Linux (GDB-Info enthalten) - C
Programm empfangenes Signal SIGSEGV, Segmentierungsfehler. 21 0x7c8024f0 in ReleaseMutex() von C: \ WINDOWS \ system32 \ kernel32.dll
Das Programm läuft auf einem Linux-System bis zur Fertigstellung. Der Absturz ist während eines rekursiven Aufruf in dieser Funktion:
void recursive_paint_char(int x,int y,int **inimage,int new_color,int fore_color)
{
/*
This routine paints the connected object around the pixel x,y in image inimage
to the color new_color. The foreground color is assumed to be fore_color.
*/
int i;
int xt,yt;
inimage[x][y]=new_color;
for (i=0;i<8;i++)
{
xt=x+xc[i];
yt=y+yc[i];
if (inimage[xt][yt]==fore_color)
{
printf("this statement prints\n");
recursive_paint_char(xt,yt,inimage,new_color,fore_color);
printf("this statement never prints\n");
}
}
}
Die Rekursion geht an über 171.000 Anrufe vor
Ich kann nicht garantieren, dass es keinen Speicherverlust auf Linux gibt, aber das Programm behandelt große Datensätze (50 Sätze von ~ 100-200 Bilder) bis zur Fertigstellung – Jake
Angenommen, Sie haben etwa 48 Bytes auf dem Stapel für jeden Anruf, 171000 Anrufe würden etwa 8MB des Stapels nehmen. Ihre Linux-Maschine ist offensichtlich für einen größeren Stapel als Ihre Windows-Maschine eingerichtet. – user3386109
Ist es nicht wichtig, dass die Rekursion tail-rekursiv ist? – Jake