[cfe-dev] clang-built binary freeze with _FORTIFY_SOURCE=2

Sylvestre Ledru sylvestre at debian.org
Mon Feb 17 01:15:27 PST 2014


Hello,

Playing with my rebuilds of Debian, I noticed that 149 packages timeout
during the build (packages
like gcc, firefox / iceweasel, llvm, mysql).

I have been able to produce a small test case which shows the freeze.
clang++ -o conftest -g  -O2  -D_FORTIFY_SOURCE=2 conftest.cpp
(note that _FORTIFY_SOURCE=2 are added by Debian & Ubuntu build systems)

--- conftest.cpp ---
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

int main ()
{
    char *data;
    int  pagesize;
    int fd, foo;
    pagesize = getpagesize ();
    fd = open ("conftest.mmap", O_RDWR);
    data = (char *) malloc (pagesize);
    foo = read (fd, data, pagesize);
}
---------
In the asm generated, clang will replace the call by __read_chk while
g++ uses read.
Any idea on how to fix that ?

It seems related to this bug:
http://llvm.org/bugs/show_bug.cgi?id=16821

If we have a fix, i think it would be a nice backport to 3.4.1.

Sylvestre




More information about the cfe-dev mailing list