clang/llvm issue with compiling gcc

Hi,

Im trying to run scan-build on GCC 4.5.3, and im running into the
following problem: Somewhere during the compilation, the process seems
to stall/freeze/hang/loop... whatever it's doing, it's not progressing
anymore.

Im running into this issue using clang version 3.0 trunk 139148. I
didnt run into this problem when compiling the same version of gcc on
the same system when using either gcc (4.5.1), or an earlier version
of clang: v3.0 trunk rev. 131083 (or slightly earlier, dont have the
exact version). I didnt run into this issue when I ran with the same
version of scan-build on other c programs (yet ?) on the same system.
It doesnt seem to be a disk/cpu/ram shortage issue.

According to 'top', 'clang' is eating up most of my cpu, but when
running strace on the pid, I get no output whatsoever. When running
strace on the 7 PID's running 'ccc-analyzer', most seem to be in
either 'wait' or 'waitpid'. Except for the ccc-analyzer that produced
the last output on my screen, wich seems to be stuck in 'read'. The 2
PID's of 'make' seem to be in wait and waitpid as well.

I have no idea on how to start with problemshooting here. Any help is welcome.

Thanks in advance,

Regards,

John Smith.

Hi John,

It sounds like the analyzer is hanging on one of your files.

Could suggestions for debugging:

1) Don't perform a parallel build.

2) Run scan-build with two extra -v -v options, which will show a very verbose log of information, including how clang is getting invoked for static analysis.

Once you find the file that it is hanging on, please file a bug report with a preprocessed file that can be used to reproduce the issue.

Cheers,
Ted

If you can grab the command-line for the invocation of clang that is
hanging (I don't know exactly what options, if any, you need for
ccc-analyzer to dump that), please file a bug at llvm.org/bugs/ with
that command-line and the preprocessed source of the file in question.

-Eli

Hi,

Ok, so I ran scan-build with -v -v options, and got a whole lot of
output. I ran 'scan-build -v -v -o /tmp/gcc make' so i didnt specify a
parallel build. According to the screen output, it seems to freeze
while analyzing 'ANALYZE: ../.././gcc/c-common.c c_define_builtins'.

I can reproduce the hang by running the exact same command line myself :

/usr/local/bin/clang -cc1 -triple i386-pc-linux-gnu -analyze
-disable-free -main-file-name c-common.c -analyzer-store=region
-analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume
-analyzer-checker=core -analyzer-checker=deadcode
-analyzer-checker=security -analyzer-checker=unix -analyzer-output
plist -w -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -target-cpu pentium4 -target-linker-version
2.20.51.0.7 -momit-leaf-frame-pointer -resource-dir
/usr/local/bin/../lib/clang/3.0 -D IN_GCC -D HAVE_CONFIG_H -I . -I .
-I ../.././gcc -I ../.././gcc/. -I ../.././gcc/../include -I
../.././gcc/../libcpp/include -I ../.././gcc/../libdecnumber -I
../.././gcc/../libdecnumber/bid -I ../libdecnumber -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -ferror-limit 19
-fmessage-length 0 -fdiagnostics-show-option
-analyzer-display-progress -analyzer-output=html -o
/tmp/gcc/2011-09-15-1 -x c ../.././gcc/c-common.c

Now where do I find this 'pre-processed' file I need to submit the bug report ?

Regards,

John Smith.

Hi John,

Try replacing "-analyze" with "-E" and "-o /tmp/gcc/2011-09-15-1" with "-o c-common.i" in the command below. That should produce the pre-processed file called c-common.i in the current directory. You can double check that it's good by running:
    $ clang --analyze c-common.i
,which should reproduce the problem.

Thanks for tracking this down,
Anna.

Thanks, that worked. I submitted bug 10933

Regards,

John Smith.

Great.

I seem to be running into similar behavior (freeze/hang) with
postgresql 9.1.0 using clang/analyzer on my Linux box.

Should I

1.) do nothing, yet.
wait until the previous submitted bug with compiling/analyzing gcc has
been resolved, then see if that fixes this as well.

2.) add to existing bug report
Assume the similar behavior has the same root cause, and try to add
the pre-processed postgresql to the existing bug report.

3.) file a new bug report
Assume the similar behavior has a different root cause, and try to
file a new bug report with the pre-processed postgresql file.

Regards,

John Smith.

This.

-eric

Ok. added bug 10936 for this one.

And one more ....

clang/analyzer hangs when compiling php 5.3.8

Bug 10942