This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

backtrace/2463: Backtracing recursive main function call


>Number:         2463
>Category:       backtrace
>Synopsis:       Backtracing recursive main function call
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 05 10:18:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     orium69@gmail.com
>Release:        gdb-6.8
>Organization:
>Environment:
Linux localhost 2.6.23.16 #2 SMP Thu Feb 28 23:17:05 WET 2008 i686 i686 i386 GNU/Linux
gcc version 4.2.3.
gdb 6.8, configured as "i686-pc-linux-gnu"

>Description:
The gdb fails to print a correct backtrace of a program which segfaults with stack overflow in function main().

See how to repeat for more details.
>How-To-Repeat:
Create a file (coiso.c) with:

int
main(int argc, char **argv)
{
	return main(argc+1,NULL);
}


Compile it and run it in gdb as shown:

[orium@localhost tmp]$ gcc -ggdb -O0 coiso.c
[orium@localhost tmp]$ gdb a.out 
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) r
Starting program: /tmp/a.out 

Program received signal SIGSEGV, Segmentation fault.
0x08048362 in main (argc=261948, argv=0x0) at coiso.c:6
6               return main(argc+1,NULL);
(gdb) bt
#0  0x08048362 in main (argc=261948, argv=0x0) at coiso.c:6
(gdb) print argc
$1 = 261948

The gdb says argc is 261948 but the stack has only one function!
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]