Bug 57933 - function dwf_regno accesses dbx_register_map beyond its upper limit
Summary: function dwf_regno accesses dbx_register_map beyond its upper limit
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-19 05:40 UTC by Vittorio Zecca
Modified: 2020-05-11 05:19 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2013-07-19 05:40:36 UTC
Compiling the following code with -m32 option
the gcc front end array extern int const dbx_register_map[FIRST_PSEUDO_REGISTER]
declared in i386.h is accessed beyond its upper limit
in function dwf_regno in dwarf2cfi.c:898.
This is because FIRST_PSEUDO_REGISTER is 53,
while REGNO (reg) is 61.
I double checked this one putting the statement
gcc_assert ( REGNO (reg) < FIRST_PSEUDO_REGISTER );
immediately before
return DWARF_FRAME_REGNUM (REGNO (reg));
in dwarf2cfi.c:898. 
The macro DWARF_FRAME_REGNUM is defined as macro DBX_REGISTER_NUMBER.
I have an x86-64 CPU with Linux Fedora 19 64 bits.
Compiler command: gcc -S -m32 p.c
/********* Code begins ****************/
void sigsetjmp (void);

typedef struct {} *S;

void __attribute__((__stdcall__))  f(S);

void  __attribute__((__force_align_arg_pointer__))
g(S hS) 
{
 sigsetjmp (); 
 f(hS);
}
/********* Code ends *******************/
p.c: In function ‘g’:
p.c:13:1: internal compiler error: in dwf_regno, at dwarf2cfi.c:898
 }
 ^
0x885bc7 dwf_regno
	../../gcc-4.8.1/gcc/dwarf2cfi.c:898
0x88bb7c dwarf2out_frame_debug
	../../gcc-4.8.1/gcc/dwarf2cfi.c:1990
0x88d80e scan_insn_after
	../../gcc-4.8.1/gcc/dwarf2cfi.c:2340
0x88e2ac scan_trace
	../../gcc-4.8.1/gcc/dwarf2cfi.c:2497
0x88e413 create_cfi_notes
	../../gcc-4.8.1/gcc/dwarf2cfi.c:2541
0x890096 execute_dwarf2_frame
	../../gcc-4.8.1/gcc/dwarf2cfi.c:2898
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
[vitti winesan]$
Comment 1 Vittorio Zecca 2020-05-11 05:19:26 UTC
Fixed.