Hi Waldek,
I applied the gdb-6.3.diff to the gdb 6.3 and now the segmentation fault stack is showed correctly. The problem is related to a rewrite operation under trap handler, it seems that the _p_Rewrite procedure received a wrong pointer to file variable.
Pascal source code which generate the segmentation fault: ------------------------------------------------------------------------
procedure tmp_opn_fnm (var p : iop_out_t; var fn: fil_spec_t; var f : text); var fs: string(fil_spec_l); tstr: TString;
procedure TrapRewriteIOErr (Trapped : Boolean); begin if Trapped then begin ioerr := true; tstr := TrappedErrorMessageString; end else begin rewrite (f,fs); end end;
begin fs := fn.body; SetLength(fs,fn.length); TrapExec(TrapRewriteIOErr); {apertura file in output} TrapReset; if (ioerr = true) then begin ios_traperr (tstr); prg_abort; end; p.trnctr := p.trnctr + [iop_opn]; end;
Segmentation Fault Stack frames: -----------------------------------------
(gdb) run Starting program: /dktlvqpe1/grfdev/ags/grfpkglnxv12/grfc.exe GRF> cc_gra_sc.smt /out= cc_gra_sc.c Program received signal SIGSEGV, Segmentation fault. 0x0807ef1a in _p_InternalOpen (f=0x0, FileName=0xbfffe238 '/dktlvqpe1/grfdev/ags/grfpkglnxv12/cc_gra_sc.111', Length=1, BufferSize=1, Mode=Fo_reset) at files.pas:1639 1639 if f^.Status.Untyped then (gdb) where #0 0x0807ef1a in _p_InternalOpen (f=0x0, FileName=0xbfffe238 '/dktlvqpe1/grfdev/ags/grfpkglnxv12/cc_gra_sc.111', Length=1, BufferSize=1, Mode=Fo_reset) at files.pas:1639 #1 0x08084fab in _p_Rewrite (f=0x0, aFileName=@0xbfffe230, FileNameGiven=true, BufferSize=1) at files.pas:3238 #2 0x0804fe9b in Traprewriteioerr.1 () at grfuxtmp.p:85 #3 0x0807311f in Docall.0 () #4 0x080732fb in dosetjmp () #5 0x080731e4 in _p__M4_Trap_S3_Trapexec () #6 0x08050024 in tmp_opn_fnm (p=@0x80a2940, fn=@0xbfffe2f0, f=@0x80a28ec) at grfuxtmp.p:94 #7 0x08051c17 in iniz () at grfcdini.p:169 #8 0x080511ce in mcm_begin () at grfcdpin.p:154 #9 0x0804b100 in main_pre (d_verb='GRF ') at grfdpmai.p:50 #10 0x0804a06c in main program () at grfidt.p:8 #11 0x0804a0e1 in main (argc=1, argv=0xbfffe494, envp=0xbfffe49c) at <implicit code>:14 (gdb) -------------------------------------------------------------------------------------------- it seems that _p_Rewrite function receives a wrong paramenter (0x0) as a reference to a file (f) variable. Does such variable (referenced by TrapExec nesting calls) to be defined with specific attributes?
Thank you very much in advance for your help.
Kind regards.
Angelo Fumagalli _________________________________________________________________
----- Original Message ----- From: "Waldek Hebisch" hebisch@math.uni.wroc.pl To: gpc@gnu.de Sent: Monday, February 27, 2006 10:31 PM Subject: Re: Problem with gpc20060215 under Red Hat Enterprise Linux ES release
Angelo Fumagalli wrote:
Running the gpc20060215 Test Suite (based on gcc-3.4.4) under the Red Hat environment, in particular:
Red Hat Enterprise Linux ES release 3 (Taroon Update 6)
as "uname -a" :
Linux tlvqpe 2.4.21-37.ELsmp #1 SMP Sep 7 13:28:55 EDT 2005 i686 i686 i386 GNU/Linux
we got some internal compiler error ...
Test Run By 4grpm on 2006-02-27 11:53:22 Native configuration is i686-pc-linux-gnu (tlvqpe) gpc 20060215, based on gcc-3.4.4, flags: -g -O3 -W -Wall -Wno-unused
=== gpc tests ===
Running target any Running testsuite ...
UNSUPPORTED: aregextest.pas FAIL: fjf932a.pas FAIL: fjf932b.pas
=== gpc Summary ===
# of tests 5057 # of expected passes 5054
TEST fjf932a.pas: p/types.c:1887:find_field: failed assertion `unreachable code' ./fjf932a.pas: In main program: ./fjf932a.pas:73: error: Internal compiler error. Please submit a full bug report to the GPC mailing list gpc@gnu.de. See URL:http://www.gnu-pascal.de/todo.html for details. failed TEST fjf932b.pas: p/types.c:1887:find_field: failed assertion `unreachable code' ./fjf932b.pas: In main program: ./fjf932b.pas:62: error: Internal compiler error. Please submit a full bug report to the GPC mailing list gpc@gnu.de. See URL:http://www.gnu-pascal.de/todo.html for details.
Thank you for the info. I have too quickly assumed that line 1887 in p/types.c will never be executed. The following should fix the problem:
--- p/types.c 15 Feb 2006 02:03:12 -0000 1.10 +++ p/types.c 27 Feb 2006 21:51:28 -0000 @@ -1884,7 +1884,6 @@ tree field2 = sorted_fields[i], ret; if (DECL_NAME (field2) == component) {
gcc_unreachable (); field = field2; break; }
Anyway, we tried to build our gpc application: no gpc compilation error found, but we got a segmentation fault when running out application:
-bash-2.05b$ ./grfc.exe GRF>cc_gra_sc.smt /out=cc_gra_sc.c Segmentation fault
then trying to use gbd:
-bash-2.05b$ gdb grfc.exe GNU gdb Red Hat Linux (6.3.0.0-1.62rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run Starting program: /dktlvqpe1/grfdev/ags/grfpkglnxv12/grfc.exe GRF>cc_gra_sc.smt /out=cc_gra_sc.c Die: DW_TAG_set_type (abbrev = 32, offset = 81793) has children: FALSE attributes: DW_AT_type (DW_FORM_ref4) constant ref: 81665 (adjusted) Dwarf Error: Cannot find type of die [in module /dktlvqpe1/grfdev/ags/grfpkglnxv12/grfc.exe] (gdb) where Die: DW_TAG_set_type (abbrev = 32, offset = 81793) has children: FALSE attributes: DW_AT_type (DW_FORM_ref4) constant ref: 81665 (adjusted) Dwarf Error: Cannot find type of die [in module /dktlvqpe1/grfdev/ags/grfpkglnxv12/grfc.exe] (gdb)
it seems to me that the our gdb versin (6.3.0.0-1.62rh) isn't compatibel with gpc20060215. Which is the proper gdb version for gpc20060215 based on gcc-3.4.4 ?
Waiting for suggestions.
Thank you very much in advance.
Angelo Fumagalli
This in a known problem with gdb -- all released gdb versions have problem with Pascal DWARF-2 debug info. You can try `-gstabs+' to choose stabs debug format. Or you may try patching gdb to get better Pascal DWARF-2 support:
http://www.math.uni.wroc.pl/~hebisch/gpc/gdb-6.3.diff
-- Waldek Hebisch hebisch@math.uni.wroc.pl