To: djgpp AT delorie DOT com Date: Thu, 27 Apr 2000 06:55:08 0000 From: "nimrod a. abing" Message-ID: Mime-Version: 1.0 X-Sent-Mail: off X-Mailer: MailCity Service Subject: Re: gdb problem or just silly me - please help X-Sender-Ip: 208.160.246.197 Organization: QUALCOMM Eudora Web-Mail (http://www.eudoramail.com:80) Content-Type: text/plain; charset=us-ascii Content-Language: en Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com On Wed, 26 Apr 2000 01:18:45 Damian Yerrick wrote: >Unless the printf() family function itself crashes the program. This >happens to me all the time when porting Allegro programs from DJGPP to >Windows, as DirectX is somewhat finicky about when the screen can be >drawn on. However, fprintf() to a logfile works fine. > for those who are curious, here's how to do it (crash the program using printf ;-) step 1. create two c source files: save as file1.c: /* start of file1.c */ char *a_string_array[] = { "Now is the time for all good men", "To destroy the earth", "And have beer parties across the galaxy.", "" }; /* end of file1.c */ save as file2.c: /* start of file2.c */ #include /* should be: extern char *a_string_array[]; */ extern char **a_string_array; int main(void) { int i=0; char *a_string; a_string = a_string_array[i]; while (a_string[0]) { printf("%s\n", a_string); i++; a_string = a_string_array[i]; } return 0; } /* end of file2.c */ step 2. compile: $ gcc -o test.exe file1.c file2.c step 3. execute: $ ./test step 4. start hair pulling Exiting due to signal SIGSEGV General Protection Fault at eip=00001629 eax=20776f4e ebx=00008318 ecx=00000000 edx=20776f4e esi=00000054 edi=0000f148 ebp=00683fe0 esp=00683fc8 program=D:\PROJECTS\DJGPP\QUICKIES\TEST.EXE cs: sel=012f base=8318a000 limit=00683fff ds: sel=0137 base=8318a000 limit=00683fff es: sel=0137 base=8318a000 limit=00683fff fs: sel=010f base=000121d0 limit=0000ffff gs: sel=0147 base=00000000 limit=0010ffff ss: sel=0137 base=8318a000 limit=00683fff App stack: [00684000..00604000] Exceptn stack: [0000f0a8..0000d168] Call frame traceback EIPs: 0x00001629 _main+37 0x00002a02 ___crt1_startup+178 $ symify test.exe $ (huh!) ponder upon ye abstraction... --- nimrod_a_abing ---------------- Hot Windows Tip: ---------------- How to free up at least 300 MB of hard disk space (as seen from the MS-DOS prompt): C:\>deltree c:\windows Delete directory "Windows" and all its subdirectories? [yn] y Deleting Windows... C:\> (don't try this at home kids... not unless you have Linux installation CDs) Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com