This is the mail archive of the libc-help@sourceware.org mailing list for the glibc 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]

Fwd: Segfaults/FPEs using -lc_p


I sent the following bug report to the Debian glibc maintainers a
month ago but I haven't heard anything back. Does anyone know if this
is a documentation problem, if this is Debian-specific breakage, or if
what I want to do just isn't well posed for whatever reason (bonus for
whatever the reason is)?

Details of failing systems (bug report at end of message):

Systems are debian/lenny AMD64, consistent behaviour across AMD Phenom
II X4 (quad core) and AMD Athlon II X2 (dual core).

ed@sagittarius:~/code/balp/src$ uname -a
Linux sagittarius 2.6.26-2-amd64 #1 SMP Wed May 12 18:03:14 UTC 2010
x86_64 GNU/Linux

ed@sagittarius:~/code/balp/src$ gcc --version
gcc (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ed@sagittarius:~/code/balp/src$ dpkg-query -W libc6 libc6-prof gcc binutils
binutils	2.18.1~cvs20080103-7
gcc	4:4.3.2-2
libc6	2.7-18lenny4
libc6-prof	2.7-18lenny4

Ed

---------- Forwarded message ----------
Date: 20 July 2010 19:17
Subject: Segfaults/FPEs using -lc_p
To: submit@bugs.debian.org


Package: libc6-prof
Version: 2.7-18lenny4

Take the example program (example1) at

http://www.ibm.com/developerworks/library/l-gnuprof.html

(source appended at end for ease of reference).

ed@sagittarius:~/tmp$ gcc example.c -pg -o example -static-libgcc -lc_p
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example
Usage ./example <No of Iterations>
ed@sagittarius:~/tmp$ ./example 100
No of iterations = 100
ed@sagittarius:~/tmp$

Now try linking any other library, e.g. zlib (4 places in link order shown):

ed@sagittarius:~/tmp$ gcc example.c -pg -o example -static-libgcc -lc_p -lz
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Floating point exception
ed@sagittarius:~/tmp$

ed@sagittarius:~/tmp$ gcc example.c -pg -o example -lz -static-libgcc -lc_p
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Floating point exception
ed@sagittarius:~/tmp$

ed@sagittarius:~/tmp$ gcc example.c -pg -o example ?-static-libgcc -lz -lc_p
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Floating point exception
ed@sagittarius:~/tmp$

ed@sagittarius:~/tmp$ gcc example.c -lz -pg -o example ?-static-libgcc -lc_p
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Floating point exception

Now try specifying -static (e.g. there are many libraries in your program)

ed@sagittarius:~/tmp$ gcc example.c -pg -o example -static -static-libgcc -lc_p
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Segmentation fault

ed@sagittarius:~/tmp$ gcc example.c -pg -o example -static-libgcc -lc_p -static
example.c: In function ‘main’:
example.c:27: warning: incompatible implicit declaration of built-in
function ‘exit’
ed@sagittarius:~/tmp$ ./example 100
Segmentation fault

Thus it appears with this version you can only use -lc_p to debug
programs with no external dependencies, because you can't link other
libraries, and if you could, you still couldn't link them statically
to get proper gprof output.

I can't find any other reference to this behaviour; if it's just a
documentation problem, I'm happy to write the documentation if someone
tells me what the actual correct behaviour is (or necessary
limitations are).

Example program:

#include <stdio.h>

int a(void) {
?int i=0,g=0;
?while(i++<100000)
?{
? ? g+=i;
?}
?return g;
}
int b(void) {
?int i=0,g=0;
?while(i++<400000)
?{
? ?g+=i;
?}
?return g;
}

int main(int argc, char** argv)
{
? int iterations;

? if(argc != 2)
? {
? ? ?printf("Usage %s <No of Iterations>\n", argv[0]);
? ? ?exit(-1);
? }
? else
? ? ?iterations = atoi(argv[1]);

? printf("No of iterations = %d\n", iterations);

? while(iterations--)
? {
? ? ?a();
? ? ?b();
? }
}


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