Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 18 Oct 2011 02:44:10 +0200 (MET DST)
From: Pavel Kankovsky <>
Subject: Re: gcc 4.6.1: glibc __sincos() issue

On Mon, 17 Oct 2011, Vasiliy Kulikov wrote:

> After building gcc 4.6.1 and making glibc compilable there is one error.
> Groff's "pic" built with glibc built with gcc 4.6.1 calls __sincos and
> goes into infinite __sincos recursion:
> [...]
> callq at _init+40 is a call to __sincos().
> In the source file (./sysdeps/ieee754/dbl-64/s_sincos.c):
>     void
>     __sincos (double x, double *sinx, double *cosx)
>     {
>         [...]
>         {
>           *sinx = sin (x);
>           *cosx = cos (x);
>         }
>     }
>     weak_alias (__sincos, sincos)
> So, it is an optimised call to sin() and cos(), which is optimised to
> call to __sincos().  However, I cannot understand how it can happen as
> sin() and cos() are defined in ./sysdeps/ieee754/dbl-64/s_sin.c as
> following:

GCC thinks the architecture provides its native sincos() and transforms
"*sinx = sin (x); *cosx = cos (x);" to "sincos (x, *sinx, *cosx);"
See <> and

But Glibc is built WITHOUT native sincos()! It should be implemented
by an FPU instructions (fsincos) (*) but what we get is generic C code--
that calls itself when compiled with the aformentioned optimization. This
is WRONG! The ancient version of Glibc is to blame here:
sysdeps/x86_64/fpu/s_sincos.S was introduced in 2.5.

You can either add the missing native implementation of sincos()
or compile Glibc with -fno-native-sincos to disable the optimization.

BTW: I find it really wierd Glibc (up to the most current version)
gets native x86_64 implementations of sinl(), cosl() etc. but not
sin(), cos() etc. (with the exception of sincos()).

Pavel Kankovsky aka Peak                          / Jeremiah 9:21        \
"For death is come up into our MS Windows(tm)..." \ 21st century edition /

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.