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;
This source is incomplete
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?
No, it should just work. Since your source is incomplete I tried to add missing parts to it. However, my completed version works fine. Have you verified that the argument to tmp_opn_fnm is initialized? The backtrace shows non-null value, but the backtrace may be inaccurate, so it is better to print value of your variable.