delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/24/07:30:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Lines: 119
X-Admin: news AT aol DOT com
From: sterten AT aol DOT com (Sterten)
Newsgroups: comp.os.msdos.djgpp
Date: 24 Jul 2004 11:26:14 GMT
References: <2914-Sat24Jul2004104537+0300-eliz AT gnu DOT org>
Organization: AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com
Subject: Re: strange error
Message-ID: <20040724072614.19398.00001790@mb-m17.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote: 


 >So far so good.  Is the address shown by GDB (0x00001cfc) identical to
 >what you see in the crash message when you run the program from the
 >command line, not under GDB?

yes:
                                                                          
      
C:\DJGPP>gcc qser3.c -O2 -o qser3.exe                                          


C:\DJGPP>qser3 16 1 5                                                          

Exiting due to signal SIGSEGV                                                  

General Protection Fault at eip=00001cfc                                       

eax=0000d270 ebx=a00f0706 ecx=00000099 edx=5ff0f90b esi=a00f067e edi=ffffff78  

ebp=0009cd60 esp=0009cd10 program=C:\DJGPP\QSER3.EXE                           

cs: sel=00a7  base=10000000  limit=0009ffff                                    

ds: sel=00af  base=10000000  limit=0009ffff                                    

es: sel=00af  base=10000000  limit=0009ffff                                    

fs: sel=008f  base=00026df0  limit=0000ffff                                    

gs: sel=00bf  base=00000000  limit=0010ffff                                    

ss: sel=00af  base=10000000  limit=0009ffff                                    

App stack: [0009cd80..0001cd80]  Exceptn stack: [0001cce0..0001ada0]           

                                                                          
      
Call frame traceback EIPs:                                                     

  0x00001cfc main+1660, file qser3.c                                           

  0x000037a8 __crt1_startup+176, file crt1.c                                   

                                                                          
      
C:\DJGPP>bfdsymif qser3.exe                                                    

                                                                          
      
C:\DJGPP>scrsav >qser9                                                         


 >Not good, you should continue the disassembly until it reaches the
 >address where it crashed (0x1cfc).  Alternatively, say
 >
 >  (gdb) disassemble 0x1c80 0x1d20

OK, I understand now that the program starts at 0x1680 <main+0>
and the error occurred at  0x1cfc


 >> And then, we still don't know the first line,
 >> where an incorrect index occurred.
 >
 >That can be found by compiling the source with switches that produce
 >assembly listing (see section 8.20 in the DJGPP FAQ, except that you
 >will also need to add the -g switch--this is a mistake in the FAQ).

..with -g it will produce non-crashing code then, despite index-overflow

 >Then you will be able to find the source line by comparing the
 >assembly listing produced by the compiler and the disassembly in the
 >debugger.
 >
 >> There can be many incorrect indices
 >>  before without the program crashing.
 >
 >If we find the machine instruction that crashed (the one at address
 >0x00001cfc), we will be able to tell the index and its value.

only the final one, where it crashed

 >Bottom line, using the debugger in such cases might need some hard
 >work, but it is always the shortest way to the solution, because it
 >saves you the need to guess.

wouldn't a compiler which checks the indices 
(I found compaq-C with google) be a shorter solution here ?

 >> I also tried to get the whole output with >>file or redir, 
 >> but failed
 >
 >What exactly did you try, and how it failed?  I use redirection with
 >the debugger all the time, and it works for me.

under DOS:
gdb qser3.exe > file
run 16 1 5   (typed blindly)
disassemble  (typed blindly)

crash, no way to escape, reboot

or :

redir -o file gdb qser3.exe
run 16 1 5   (typed blindly)
disassemble  (typed blindly)
quit (typed blindly)
quit (now displayed)
<break>
XX
...

crash, no way to escape, reboot


--Guenter.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019