Linux Portability Issues

Sapna Modi sapnam@lsrc.mahyco.com
Fri Jun 6 11:23:00 GMT 2003


Hello,
	
Thanks for the reply. The core file is not with me. So that I couldn't 
check. 

As I already said mine software is working very nicely on RH linux 
7.1 with glibc version glibc-2.2.2-10.

And now on RH linux 9.0, the glibc version is glibc-2.3.2-11.9, it is 
giving problem of segmentation fault.

>From the output of gdb, it shows problem in fclose@glic....

Program received signal SIGSEGV, Segmentation fault.
0x42061367 in fclose@@GLIBC_2.1 () from /lib/tls/libc.so.6
(gdb)                                                    

So is it the case that with the changed version of glibc, the 
software is not running.

Following is the part of the code that refers to fclose---
 
  #include<stdio.h>

   FILE *fd;                      /* file pointer */   

   fd=fopen("test.txt","r");  /* open the file */

   if(fd == NULL)
   {
        printf("\n Error in opening the file");
        exit(1);
   }

   while(feof(fd) == 0)
   {    /* while */                                  
	
 		/* some code */

   }  /* end while */


   if(feof(fd) != 0)
   {
      clearerr(fd);
   }


   if(fclose(fd) == 0)
   {
    	printf("\n Successfully closed file");
   }

   printf("\n main end");      /* #testing */

}       /* end main */                            

Please help.
--Sapna

---------------------------0--o--0--o--0--o--0----------------------------------------------
            Learn By Listening. Understand By Reflecting.
---------------------------0--o--0--o--0--o--0----------------------------------------------



On 5 Jun 03, at 6:24, John Love-Jensen wrote:

Hi Sapna,

Probably a lurking bug in the code.  (Your code?  GCC?  Other?  Don't know.)

To solve the problem, use gdb to look at the core file and see where it
crashed.  Assuming you have a core file on hand.

If that doesn't help you figure out why it crashed, use gdb to step through
the code.

Good luck,
--Eljay




More information about the Gcc-help mailing list