Public bug reported: Under gcc 4.1.1-6ubuntu3 and both Linux 2.6.17-11-386 and Linux 2.6.17.14-ubuntu1-systemtap, the address of argc is changing when certain functions are called. When printf()s that reference argc are interleaved with the offending code, the error disappears. Binaries compiled with this version of gcc continue to have this problem on other Linux distributions (eg FC5). All of this testing is on the i386 architecture.
Example: ... server_socket = socket(AF_INET, SOCK_STREAM, 0); // argc = 1 bind(server_socket, (struct sockaddr *) &server_addr, sizeof(server_addr)); // argc = 2 ?? listen(server_socket, LISTEN_BACKLOG); size_client_addr = sizeof(client_addr); ... gdb output: (showing change) Breakpoint 1, main (argc=1, argv=0xbfba78a4) at server.c:107 107 server_socket = socket(AF_INET, SOCK_STREAM, 0); (gdb) c Continuing. Breakpoint 2, main (argc=2, argv=0xbfba78a4) at server.c:108 108 bind(server_socket, (struct sockaddr *) &server_addr, ... gdb output (showing address change): (gdb) b 107 Breakpoint 1 at 0x80487c1: file server.c, line 107. (gdb) b 108 Breakpoint 2 at 0x80487e0: file server.c, line 108. (gdb) c The program is not being run. (gdb) r Starting program: /home/me/tmp/HiRCServer Breakpoint 1, main (argc=1, argv=0xbfe14b14) at server.c:107 107 server_socket = socket(AF_INET, SOCK_STREAM, 0); (gdb) p &argc $1 = (const int *) 0xbfe14a90 (gdb) c Continuing. Breakpoint 2, main (argc=2, argv=0xbfe14b14) at server.c:108 108 bind(server_socket, (struct sockaddr *) &server_addr, (gdb) p &argc $2 = (const int *) 0xbfe03e10 ---- This condition does not appear itself with gcc 4.1.1 on Fedora Core 5 or gcc 3.4.3 under Solaris Express. Screenshots, binaries, and code causing this issue: http://acm.jhu.edu/~me/gcc-ubuntu-edgy/ ** Affects: gcc-defaults (Ubuntu) Importance: Undecided Status: Unconfirmed -- Address of argc changes when certain functions are called. https://launchpad.net/bugs/84926 -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs