X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Message-ID: <50420942.7090804@iki.fi> Date: Sat, 01 Sep 2012 16:10:26 +0300 From: Andris Pavenis User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120425 Thunderbird/13.0 MIME-Version: 1.0 To: Juan Manuel Guerrero CC: djgpp AT delorie DOT com Subject: Re: gcc behaviour if djgpp.env is not available. References: <201208302244 DOT 31877 DOT juan DOT guerrero AT gmx DOT de> In-Reply-To: <201208302244.31877.juan.guerrero@gmx.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com On 30.8.2012 23:44, Juan Manuel Guerrero wrote: > I do not know if this issue has already been discused but I have noticed > that the DJGPP port of gcc crashes if it does not find djgpp.env. If gcc > needs to load djgpp.env and fails, would not it be better that it issues > some kind of error message instead of crashing? > For an user not familiar with DJGPP it would be hard to figure out > what has gone wrong. > > The output below is produced by gcc471b on WinXP after having deleted > djgpp.env. Did some debugging (gdb xgcc.exe, command line parameters -B./ -print-prog-name=cc1) The crash is in src/crt0/crt0.S in dos_alloc_ok(). ---Type to continue, or q to quit--- 0x00001ba3 <+170>: sub $0x1000,%eax 0x00001ba8 <+175>: push %eax 0x00001ba9 <+176>: call 0x1d0d 0x00001bae <+181>: mov %fs:0x18,%eax 0x00001bb4 <+187>: mov %eax,0x17e3e0 0x00001bb9 <+192>: mov %fs:0x10,%eax 0x00001bbf <+198>: push %eax 0x00001bc0 <+199>: call 0x1d30 <__sbrk> 0x00001bc5 <+204>: cmp $0xffffffff,%eax 0x00001bc8 <+207>: je 0x1c46 0x00001bca <+209>: mov %eax,0x17ebec 0x00001bcf <+214>: mov %eax,%edi 0x00001bd1 <+216>: mov %fs:0x10,%ecx 0x00001bd8 <+223>: shr $0x2,%ecx 0x00001bdb <+226>: xor %esi,%esi 0x00001bdd <+228>: push %ds 0x00001bde <+229>: push %fs 0x00001be0 <+231>: pop %ds 0x00001be1 <+232>: cld => 0x00001be2 <+233>: rep movsl %ds:(%esi),%es:(%edi) 0x00001be4 <+235>: pop %ds 0x00001be5 <+236>: mov 0x17e3d8,%eax 0x00001bea <+241>: mov %fs:0x14,%ecx 0x00001bf1 <+248>: cmp %ecx,%eax 0x00001bf3 <+250>: jge 0x1bfc 0x00001bf5 <+252>: mov %ecx,%eax 0x00001bf7 <+254>: mov %eax,0x17e3d8 End of assembler dump. (gdb) info reg eax 0xaa10000 178323456 ecx 0xc58c8cf 207145167 edx 0x3c050000 1006960640 ebx 0x374 884 esp 0x302114 0x302114 ebp 0x158 0x158 esi 0x4000 16384 edi 0xaa14000 178339840 eip 0x1be2 0x1be2 eflags 0x13246 [ PF ZF IF #12 #13 RF ] cs 0x1ef 495 ss 0x1f7 503 ds 0x1e7 487 es 0x1f7 503 fs 0x1e7 487 gs 0x207 519 Checked also with my last build of upcoming gcc-4.8.0 snapshot: G:\build.gcc\gcc>.\xgcc -v Using built-in specs. COLLECT_GCC=g:/build.gcc/gcc/xgcc.exe Target: djgpp Configured with: /v204/gcc-4.80-20120825/configure djgpp --prefix=/dev/env/DJDIR --disable-nls --disable-werror --enable-languages=c,c++,fortran,objc,obj-c++,ad a --enable-libquadmath-support --disable-lto --disable-build-poststage1-with-cxx Thread model: single gcc version 4.8.0 20120825 (experimental) (GCC) G:\build.gcc\gcc>set DJGPP= G:\build.gcc\gcc>.\xgcc -v xgcc.exe: fatal error: environment variable DJGPP not defined compilation terminated. G:\build.gcc\gcc>xgcc -B./ -print-prog-name=cc1 xgcc.exe: fatal error: environment variable DJGPP not defined compilation terminated. In this case GCC behaved as it should. But it is perhaps not the best case for comparison (now the GCC 4.8.0 is using C++ not C any more) Both v2.03 and v2.04 builds of gcc-4.7.1 crashes when DJGPP is not defined. Debugging done with v2.04 build. Andris > > F:\x\XZ-50~1.4\_build.204\_build.tmp>gcc 1.c > Exiting due to signal SIGSEGV > General Protection Fault at eip=00001be2 > eax=0c720000 ebx=00000299 ecx=0b93d411 edx=3ac30000 esi=00010000 edi=0c730000 > ebp=00000158 esp=00302114 program=C:\DJGPP-2.04\BIN\GCC.EXE > cs: sel=01a7 base=02990000 limit=3ac2ffff > ds: sel=017f base=00008aa0 limit=0000ffff > es: sel=01af base=02990000 limit=3ac2ffff > fs: sel=017f base=00008aa0 limit=0000ffff > gs: sel=01bf base=00000000 limit=0010ffff > ss: sel=01af base=02990000 limit=3ac2ffff > App stack: [00302470..00182470] Exceptn stack: [00182390..00180450] > > Call frame traceback EIPs: > 0x00001be2 > > > > Regards, > Juan M. Guerrero > > >