building llvm head on ubuntu with glibc-2.3.6


I’m trying to build llvm cvs head on Ubuntu. make command fails with this (VERBOSE=1):

llvm[1]: Building Intrinsics.gen.tmp from
/home/ubuntu/llvm/obj/Debug/bin/tblgen -I /home/ubuntu/llvm/src/lib/VMCore -I/home/ubuntu/llvm/src/include -I /home/ubuntu/llvm/src/lib/Target /home/ubuntu/llvm/src/include/llvm/ -o /home/ubuntu/llvm/obj/lib/VMCore/Debug/Intrinsics.gen.tmp -gen-intrinsic
*** glibc detected *** /home/ubuntu/llvm/obj/Debug/bin/tblgen: malloc(): memory corruption: 0x081f8a70 ***
======= Backtrace: =========
======= Memory map: ========
08048000-081ea000 r-xp 00000000 08:01 429715 /home/ubuntu/llvm/obj/Debug/bin/tblgen
081ea000-081eb000 rw-p 001a2000 08:01 429715 /home/ubuntu/llvm/obj/Debug/bin/tblgen
081eb000-0824e000 rw-p 081eb000 00:00 0 [heap]
40000000-40019000 r-xp 00000000 08:01 242581 /lib/
40019000-4001b000 rw-p 00018000 08:01 242581 /lib/
4001b000-4001d000 rw-p 4001b000 00:00 0
40029000-40038000 r-xp 00000000 08:01 278691 /lib/tls/i686/cmov/
40038000-4003a000 rw-p 0000f000 08:01 278691 /lib/tls/i686/cmov/libpthread-
4003a000-4003c000 rw-p 4003a000 00:00 0
4003c000-4003e000 r-xp 00000000 08:01 278680 /lib/tls/i686/cmov/
4003e000-40040000 rw-p 00001000 08:01 278680 /lib/tls/i686/cmov/libdl-
40040000-40114000 r-xp 00000000 08:01 664497 /usr/lib/
40114000-40117000 r–p 000d4000 08:01 664497 /usr/lib/
40117000-40119000 rw-p 000d7000 08:01 664497 /usr/lib/
40119000-40120000 rw-p 40119000 00:00 0
40120000-40144000 r-xp 00000000 08:01 278681 /lib/tls/i686/cmov/
40144000-40146000 rw-p 00023000 08:01 278681 /lib/tls/i686/cmov/libm-
40146000-40150000 r-xp 00000000 08:01 242467 /lib/
40150000-40151000 rw-p 00009000 08:01 242467 /lib/
40151000-4027e000 r-xp 00000000 08:01 278677 /lib/tls/i686/cmov/libc-
4027e000-40280000 r–p 0012c000 08:01 278677 /lib/tls/i686/cmov/
40280000-40282000 rw-p 0012e000 08:01 278677 /lib/tls/i686/cmov/libc-
40282000-4068a000 rw-p 40282000 00:00 0
40700000-40721000 rw-p 40700000 00:00 0
40721000-40800000 —p 40721000 00:00 0
bfea0000-bfeb6000 rw-p bfea0000 00:00 0 [stack]
ffffe000-fffff000 —p 00000000 00:00 0 [vdso]
make[1]: *** [/home/ubuntu/llvm/obj/lib/VMCore/Debug/Intrinsics.gen.tmp] Aborted (core dumped)
make[1]: *** Deleting file /home/ubuntu/llvm/obj/lib/VMCore/Debug/Intrinsics.gen.tmp' make[1]: Leaving directory /home/ubuntu/llvm/obj/lib/VMCore’
make: *** [all] Error 1

Bt leads through standart C++ library calls to the following line (109) in utils/TableGen/TableGen main() function:

Out = new std::ofstream(OutputFilename.c_str());

As for me the TableGen code seems ok (especially because a lot of people build llvm everyday). I tried to compile llvm with both gcc-3.4.6 and gcc-4.0.1 but the same error occurs. So I think that either glibc version is buggy or llvm is not compatible with the latest version ( glibc-2.3.6) I use. The first case don’t seem very reasonable because of what I have investigated with Google (most projects leading to similar malloc error are said by its support to be out of date). The latter is not reasonable until it turns out that everybody working on llvm head use some previous versions of glibc (a bit possible though). Probably, some right reason remains I can’t think of (some other lib is not installed/updated?).

Any thoughts on the issue described will be appreciated. I’ll provide any information needed.

Thanks in advance.


Hi Anton,

I have only one thought on the problem below. The line of code where
glibc detects the memory corruption is not the line of code where the
bug occurs. It occurred sometime before that. I.e. memory got corrupted
at some point and it isn't reported until the next malloc call. You
might be able to find it by code inspection if there isn't much code
between this malloc and the (dynamically) previous one. If that doesn't
bear any fruit, please run tblgen under valgrind and find out exactly
where the memory corruption occurs. Feel free to open a problem report
on this at