Mail Archives: djgpp/2004/02/29/07:31:25
I get this error when booting DOS from floppy (DOS from Win98)
C:\PANCAKE>a:sprc kkk
Exiting due to signal SIGSEGV
Page fault at eip=0000171c, error=0004
eax=00000000 ebx=000a098c ecx=00000005 edx=0000d500 esi=00000054 edi=000a0974
ebp=000a07b0 esp=000a0790 program=a:\SPRC.EXE
cs: sel=00a7 base=10000000 limit=000affff
ds: sel=00af base=10000000 limit=000affff
es: sel=00af base=10000000 limit=000affff
fs: sel=008f base=00030f20 limit=0000ffff
gs: sel=00bf base=00000000 limit=0010ffff
ss: sel=00af base=10000000 limit=000affff
App stack: [000a07d4..000207d4] Exceptn stack: [00020730..0001e7f0]
Call frame traceback EIPs:
0x0000171c _main+60
0x000038c8 ___crt1_startup+176
C:\PANCAKE>symify sprc.exe
for the program below, compiled with gcc sprc.c -O2 -g -o sprc.exe
It runs correctly in a DOS box under Win98.
any ideas how to correct it ?
#include <stdio.h>
FILE *file1;
int A[122][122],Min[222],I[222],F[222],Node[222]={0},zz[99]={0};
int im,x,y,z,i,j,k,kj,n,a,ii,c,a1,a2,a3,a4,a5,f,adj,solus,node=0,max=0;
char qwe;
int getnumber();
int spr();
int adjacencies();
int main(int argc,char* argv[]){
if(argc<2){printf("\n\nusage:spr file [n,s] \n\n");
printf("sorts permutations by prefix reversal\n");
printf(" n : prints nodecounts\n");
printf(" p : prints solution\n");
printf(" s : prints nodecounts + all best solutions are
counted\n");
printf(" v : prints partial results \n");
;exit(1);}
if((file1=fopen(argv[1],"rb"))==NULL){printf("file-error");exit(1);}
qwe=argv[2][0];
m0:n=1;
m1:A[0][n]=getnumber();
if(A[0][n]<0)n--;
if(a!=13){n++;goto m1;}
// if(A[0][n]<0)n--;
//for(j=1;j<=n;j++)printf("%i ",A[0][j]);printf(" %i\n",n);
c=spr();for(j=1;j<=n;j++)printf("%i ",A[0][j]);printf(" %i\n",c);
if(qwe=='p'){for(j=1;j<=i;j++)printf("%i ",I[j]);printf("\n");}
if(qwe=='n'||argv[2][0]=='s'){k=0;for(j=0;j<=i;j++){k+=Node[j];printf("%i
",Node[j]);}printf(" %i %i\n",k,zz[0]);}
if(feof(file1)==0)goto m0;
if(qwe=='v'){printf("\n\n");for(i=0;i<10;i++)printf("%i ",zz[i]);printf("\n");}
fclose(file1);
}
//--------------------------------------------------------------
int spr(){
for(i=0;i<=n+33;i++)Node[i]=0;
i=0;adj=adjacencies();f=n-adj;
if(adj==n)return 0;
m70:for(i=0;i<222;i++)Min[i]=0;max=0;
solus=0;i=0;F[0]=adj;
m80:i++;I[i]=1;
m100:ii=I[i]+1;I[i]=ii;if(ii>n)goto m170;
if(ii==n && A[i-1][n]==n)goto m100;
k=F[i-1];
if(ii==n){if(A[i-1][1]==n)k++;goto m110;}
if(abs(A[i-1][1]-A[i-1][ii+1])==1)k++;
if(abs(A[i-1][ii]-A[i-1][ii+1])==1)k--;
m110:if(k<Min[i])goto m100;
if(n-k+i>f)goto m100;
Min[i]=k;if(i>max){max=i;
if(qwe=='n'){
for(j=0;j<=i;j++)printf("%i ",I[j]);printf(" %i %i\n",f,max);
printf("-");for(j=1;j<=n;j++)printf("%i ",A[i-1][j]);printf(" %i
%i\n",f,max);
}}
node++;if(node==1000000){node=0;
if(qwe=='n'){for(j=0;j<n;j++)printf("%i ",Node[j]);printf("\n");}}
ii=I[i];for(j=1;j<=ii;j++){A[i][j]=A[i-1][ii+1-j];}
for(j=ii+1;j<=n;j++){A[i][j]=A[i-1][j];}
F[i]=k;Node[i]++;
if(F[i]==n){solus++;im=i;if(qwe!='s')return i;}
goto m80;
m170:i--;if(i>0)goto m100;
f++;
if(qwe=='v')printf("--%i %i %i--\n",n,f,adj);
if(solus==0)goto m70;
i=im;return i;
}
int adjacencies(){
j=0;if(A[i][n]==n)j++;
for(kj=1;kj<n;kj++)if(A[i][kj]+1==A[i][kj+1] || A[i][kj]==A[i][kj+1]+1)j++;
return j;}
int getnumber(){
gnu1:if(feof(file1)==0)goto gnu6;
fin3:if(qwe=='v'){printf("\n\n");for(i=0;i<10;i++)printf("%i
",zz[i]);printf("\n");}
exit(0);
gnu6: a=fgetc(file1);
if(a==13 || a==10)return -1;
if(a<48||a>57)goto gnu1;c=a-48;
gnu2:if(feof(file1))goto fin3;a=fgetc(file1);
if(a>47&&a<58){c=c*10+a-48;goto gnu2;}
return c ;}
- Raw text -