load with libc_p.a causes floating exception

Bug #193487 reported by rick pember on 2008-02-19
18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Debian)
Fix Released
Unknown
glibc (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: libc6-prof

I'm trying to profile a code that's I/O intensive and so I would like to
use the profiling version of the C library, libc_p.a. In a nutshell, executables
compiled with gcc with -p (or -pg) and linked with libc_p.a have a floating
point exception right out the gate. (I also have the Intel C compiler installed,
icc, and the same is true.)

This is true for all versions of gcc I have installed, except for 2.95, for
which the link fails.

For (the simplest) example:

-------------------------------------------------------------------------
%coot 108: cat hello.c
#include <stdio.h>

main() {

  printf ("hello, world!\n");

}
%coot 109: gcc hello.c
%coot 110: a.out
hello, world!
%coot 111: gcc hello.c -lc_p
%coot 112: a.out
hello, world!
%coot 113: gcc -p hello.c -lc_p
%coot 114: a.out
Floating exception
%coot 115: gcc -p hello.c
%coot 116: a.out
hello, world!
%coot 117: gcc -pg hello.c
%coot 118: a.out
hello, world!
%coot 119: gcc -p hello.c -lc_p
%coot 120: a.out
Floating exception
%coot 121: gcc -pg hello.c -lc_p
%coot 122: a.out
Floating exception
%coot 123: gcc-3.3 -pg hello.c -lc_p
%coot 124: a.out
Floating exception
%coot 125: gcc-3.4 -pg hello.c -lc_p
%coot 126: a.out
Floating exception
%coot 127: gcc-4.2 -pg hello.c -lc_p
%coot 128: a.out
Floating exception
%coot 129: gcc-2.95 hello.c
%coot 130: a.out
hello, world!
%coot 131: gcc-2.95 -pg hello.c
%coot 132: a.out
hello, world!
%coot 133: gcc-2.95 -pg hello.c -lc_p
/usr/bin/../lib/libc_p.a(syslog.op): In function `__vsyslog_chk':
(.text+0x70e): undefined reference to `_Unwind_Resume'
(blah-blah-blah)
%coot 134:
--------------------------------------------------------------------------

I'm using the version of libc_p.a found in the Synaptic Package manger (SPM) under libc6-prof.
The versions of gcc were also found under the SPM.

I found in the Synaptic Package manger (SPM) under libc6-prof.

I've also installed gcc in the same way. Under the SPM, versions 2.95,
3.3., 3.4, 4.1, and 4.2 are available. The base version is 4.1:

-----------------------------------------
%coot 104: gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
%coot 105:
-----------------------------------

I have a neighbor running Red Hat with gcc 3.2.3, and I am able to build and run there, so I know I'm otherwise "doing the right thing:"
-----------------------------------------------------------------------------------------------------------------------------------------------
[pember@tern _gprof]$ gcc -p hello.c -lc_p
[pember@tern _gprof]$ ./a.out
hello, world!
[pember@tern _gprof]$
-----------------------------------------------------------------------------------------------------------------------------------------------

Other info:
----------------------------------------------------------------------
%coot 134: cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"
%coot 136: dpkg -l gcc | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-================-============================================
ii gcc 4:4.1.2-9ubuntu2 The GNU C compiler
%coot 137: dpkg -l gcc-3.3 | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-=================-============================================
ii gcc-3.3 1:3.3.6-15ubuntu2 The GNU C compiler
%coot 138: dpkg -l gcc-3.4 | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii gcc-3.4 3.4.6-6ubuntu2 The GNU C compiler
%coot 139: dpkg -l gcc-4.1 | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-===============-============================================
ii gcc-4.1 4.1.2-16ubuntu2 The GNU C compiler
%coot 140: dpkg -l gcc-4.2 | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii gcc-4.2 4.2.1-5ubuntu4 The GNU C compiler
%coot 143: dpkg -l libc6-prof
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=======================-=======================-==============================================================
ii libc6-prof 2.6.1-1ubuntu10 GNU C Library: Profiling Libraries
------------------------------------------------------------------------------------------------------

Thanks,
Rick Pember

Matthias Klose (doko) wrote :

could this be rechecked with hardy (8.04), or intrepid (8.10 development)?

Changed in glibc:
status: New → Incomplete
Download full text (7.1 KiB)

I'm ashamed to say I haven't updated from 7.10 yet. I've been in a bit of a
crunch
at work and don't have the time to deal with issues that might arise. 7.10
is the first Linux
I've ever installed myself and been responsible for -- no sys admin -- so
maybe I'm being too
paranoid. Maybe next month.

On Mon, Sep 8, 2008 at 5:47 PM, Matthias Klose <email address hidden> wrote:

> could this be rechecked with hardy (8.04), or intrepid (8.10
> development)?
>
> ** Changed in: glibc (Ubuntu)
> Status: New => Incomplete
>
> --
> load with libc_p.a causes floating exception
> https://bugs.launchpad.net/bugs/193487
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in "glibc" source package in Ubuntu: Incomplete
>
> Bug description:
> Binary package hint: libc6-prof
>
> I'm trying to profile a code that's I/O intensive and so I would like to
> use the profiling version of the C library, libc_p.a. In a nutshell,
> executables
> compiled with gcc with -p (or -pg) and linked with libc_p.a have a floating
> point exception right out the gate. (I also have the Intel C compiler
> installed,
> icc, and the same is true.)
>
> This is true for all versions of gcc I have installed, except for 2.95, for
> which the link fails.
>
> For (the simplest) example:
>
> -------------------------------------------------------------------------
> %coot 108: cat hello.c
> #include <stdio.h>
>
> main() {
>
> printf ("hello, world!\n");
>
> }
> %coot 109: gcc hello.c
> %coot 110: a.out
> hello, world!
> %coot 111: gcc hello.c -lc_p
> %coot 112: a.out
> hello, world!
> %coot 113: gcc -p hello.c -lc_p
> %coot 114: a.out
> Floating exception
> %coot 115: gcc -p hello.c
> %coot 116: a.out
> hello, world!
> %coot 117: gcc -pg hello.c
> %coot 118: a.out
> hello, world!
> %coot 119: gcc -p hello.c -lc_p
> %coot 120: a.out
> Floating exception
> %coot 121: gcc -pg hello.c -lc_p
> %coot 122: a.out
> Floating exception
> %coot 123: gcc-3.3 -pg hello.c -lc_p
> %coot 124: a.out
> Floating exception
> %coot 125: gcc-3.4 -pg hello.c -lc_p
> %coot 126: a.out
> Floating exception
> %coot 127: gcc-4.2 -pg hello.c -lc_p
> %coot 128: a.out
> Floating exception
> %coot 129: gcc-2.95 hello.c
> %coot 130: a.out
> hello, world!
> %coot 131: gcc-2.95 -pg hello.c
> %coot 132: a.out
> hello, world!
> %coot 133: gcc-2.95 -pg hello.c -lc_p
> /usr/bin/../lib/libc_p.a(syslog.op): In function `__vsyslog_chk':
> (.text+0x70e): undefined reference to `_Unwind_Resume'
> (blah-blah-blah)
> %coot 134:
> --------------------------------------------------------------------------
>
> I'm using the version of libc_p.a found in the Synaptic Package manger
> (SPM) under libc6-prof.
> The versions of gcc were also found under the SPM.
>
> I found in the Synaptic Package manger (SPM) under libc6-prof.
>
> I've also installed gcc in the same way. Under the SPM, versions 2.95,
> 3.3., 3.4, 4.1, and 4.2 are available. The base version is 4.1:
>
> -----------------------------------------
> %coot 104: gcc -v
> Using built-in specs.
> Target: i486-linux-gnu
> Configured with: ../src/configure -v
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
> --ena...

Read more...

Zakalwe (elethiomel) wrote :

I can confirm this problem on Intrepid

Arch : x86_64
GCC : 4.3.2 (Ubuntu 4.3.2-1ubuntu11)
Libc-prof : 2.8~20080505-0ubuntu7

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x7fe4c3766780 (LWP 24118)]
0x0000000000412451 in profil ()
Current language: auto; currently asm
(gdb) bt
#0 0x0000000000412451 in profil ()
#1 0x00000000004121f2 in monstartup ()
#2 0x0000000000406d31 in __gmon_start__ () at gmon-start.c:74
#3 0x00007fe4c241e2b2 in call_gmon_start () from /lib/librt.so.1
#4 0x0000000000000000 in ?? ()

Changed in glibc:
status: Unknown → Fix Released

The fix should already be pulled from debian. Is this still a problem with Jaunty? Thanks.

Martin Ivanov (martinvivanov) wrote :

I can confirm this for Jaunty, libc6-2.9.4 on x86-64. Apps linked with -lc_p give floating point exception the moment you run them. Here's what GDB has to say:

Program received signal SIGFPE, Arithmetic exception.
0x00000000004c8551 in profil ()
Current language: auto; currently asm
(gdb) bt
#0 0x00000000004c8551 in profil ()
#1 0x00000000004c82f2 in monstartup ()
#2 0x0000000000406441 in __gmon_start__ () at gmon-start.c:74
#3 0x00007fe1ae648c72 in ?? () from /lib/libgcc_s.so.1
#4 0x0000000000000000 in ?? ()

Michael B. Trausch (mtrausch) wrote :

The problem does indeed still exist in Jaunty; I just ran into it here (Jaunty on x86-64). In order to build something with -pg, -lc_p must not be used or SIGFPE results.

Changed in glibc (Ubuntu):
status: Incomplete → Confirmed
Michael B. Trausch (mtrausch) wrote :

This still occurs in Hardy. If the workaround listed in the Debian bug is used, instead of catching SIGFPE, it catches SIGSEGV.

Matthias H. (matthias-h) wrote :

Here is my, eventually successful, results on Ubuntu 9.10 Karmic Koala after installing libc6-prof. Please refer to /usr/share/doc/libc6-prof/README.Debian
--------------
user@mymachine:~/work$ cat test.c
#include <stdio.h>

int main()
{
        printf("Hello World!\n");
        return 0;
}
user@mymachine:~/work$ gcc -o test test.c
user@mymachine:~/work$ ./test
Hello World!
user@mymachine:~/work$ gcc -pg -o test test.c
user@mymachine:~/work$ ./test
Hello World!
user@mymachine:~/work$ gcc -pg -o test test.c -lc_p
user@mymachine:~/work$ ./test
Floating point exception (core dumped)
user@mymachine:~/work$ gcc -pg -o test test.c -static-libgcc -lc_p
user@mymachine:~/work$ ./test
Segmentation fault (core dumped)
user@mymachine:~/work$ ll /usr/bin/gcc
lrwxrwxrwx 1 root root 7 2009-10-30 11:26 /usr/bin/gcc -> gcc-4.4
user@mymachine:~/work$ gcc-4.1 -pg -o test test.c -static-libgcc -lc_p
user@mymachine:~/work$ ./test
Hello World!
user@mymachine:~/work$

Ian Hutchinson (hutch) wrote :

Same problems as everyone else
$ uname -a
Linux tp400-64 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:02:15 UTC 2009 x86_64 GNU/Linux
$gfortran -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)

I take it the "fix" means we can't actually use libc_p in a standard Karmic system, since we don't have gcc-4.1
Even if I had, or installed gcc-4.1, I don't suppose we'd be able to use it for gfortran compiling. Is that right?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.