[cfe-dev] glibc detected with Clang trunk on 64-bit Fedora Linux

Matthias Vallentin vallentin at icir.org
Tue Jul 10 09:19:59 PDT 2012


I get a segfault when running the following program:

    #include <string>
    #include <vector>
    #include <cstddef>
    #include <iostream>
    #include <typeinfo>
    #include <cxxabi.h>

    using std::cerr;
    using std::cout;
    using std::endl;

    int main() {
        std::vector<const std::type_info*> tinfos{&typeid(int), &typeid(float), &typeid(std::string),&typeid(char16_t)};
        for (auto ptr : tinfos) {
            size_t size;
            int status;
            char* undecorated = abi::__cxa_demangle(ptr->name(), nullptr, &size, &status);
            if (status != 0) {
                cerr << "could not demangle type name \"" << ptr->name() << "\"" << endl;
            }   
            cout << "\"" << ptr->name() << "\" => \"" << undecorated << "\"" << endl; 
            if (undecorated) free(undecorated);
        }   
        return 0;
    }

I compiled it as follows:

    clang++ -L/opt/llvm/lib -std=c++11 -stdlib=libc++ test.cc -lcxxrt

The box is a 64-bit Fedora Linux and I am using the trunk versions of
both Clang and libcxxrt. The error message I get is:

    "i" => "int"
    "f" => "float"
    "NSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE" => "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"
    *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x0000000000602d10 ***
    ======= Backtrace: =========
    /lib64/libc.so.6[0x3190e7703a]
    /opt/llvm/lib/libcxxrt.so(__cxa_demangle+0xcc)[0x7fe3fc4204c6]
    ./a.out[0x401392]
    /lib64/libc.so.6(__libc_start_main+0xed)[0x3190e2139d]
    ./a.out[0x400ed9]
    ======= Memory map: ========
    00400000-00403000 r-xp 00000000 fd:00 697                                /tmp/a.out
    00602000-00603000 rw-p 00002000 fd:00 697                                /tmp/a.out
    00b7a000-00b9b000 rw-p 00000000 00:00 0                                  [heap]
    3190a00000-3190a1f000 r-xp 00000000 fd:00 1054                           /lib64/ld-2.14.so
    3190c1e000-3190c1f000 r--p 0001e000 fd:00 1054                           /lib64/ld-2.14.so
    3190c1f000-3190c20000 rw-p 0001f000 fd:00 1054                           /lib64/ld-2.14.so
    3190c20000-3190c21000 rw-p 00000000 00:00 0
    3190e00000-3190f8f000 r-xp 00000000 fd:00 1058                           /lib64/libc-2.14.so
    3190f8f000-319118f000 ---p 0018f000 fd:00 1058                           /lib64/libc-2.14.so
    319118f000-3191193000 r--p 0018f000 fd:00 1058                           /lib64/libc-2.14.so
    3191193000-3191194000 rw-p 00193000 fd:00 1058                           /lib64/libc-2.14.so
    3191194000-319119a000 rw-p 00000000 00:00 0
    3191200000-3191216000 r-xp 00000000 fd:00 1061                           /lib64/libpthread-2.14.so
    3191216000-3191415000 ---p 00016000 fd:00 1061                           /lib64/libpthread-2.14.so
    3191415000-3191416000 r--p 00015000 fd:00 1061                           /lib64/libpthread-2.14.so
    3191416000-3191417000 rw-p 00016000 fd:00 1061                           /lib64/libpthread-2.14.so
    3191417000-319141b000 rw-p 00000000 00:00 0
    3191600000-3191683000 r-xp 00000000 fd:00 461                            /lib64/libm-2.14.so
    3191683000-3191882000 ---p 00083000 fd:00 461                            /lib64/libm-2.14.so
    3191882000-3191883000 r--p 00082000 fd:00 461                            /lib64/libm-2.14.so
    3191883000-3191884000 rw-p 00083000 fd:00 461                            /lib64/libm-2.14.so
    3191a00000-3191a02000 r-xp 00000000 fd:00 1099                           /lib64/libdl-2.14.so
    3191a02000-3191c02000 ---p 00002000 fd:00 1099                           /lib64/libdl-2.14.so
    3191c02000-3191c03000 r--p 00002000 fd:00 1099                           /lib64/libdl-2.14.so
    3191c03000-3191c04000 rw-p 00003000 fd:00 1099                           /lib64/libdl-2.14.so
    3191e00000-3191e07000 r-xp 00000000 fd:00 1068                           /lib64/librt-2.14.so
    3191e07000-3192006000 ---p 00007000 fd:00 1068                           /lib64/librt-2.14.so
    3192006000-3192007000 r--p 00006000 fd:00 1068                           /lib64/librt-2.14.so
    3192007000-3192008000 rw-p 00007000 fd:00 1068                           /lib64/librt-2.14.so
    3192600000-3192615000 r-xp 00000000 fd:00 1182                           /lib64/libgcc_s-4.6.1-20110908.so.1
    3192615000-3192814000 ---p 00015000 fd:00 1182                           /lib64/libgcc_s-4.6.1-20110908.so.1
    3192814000-3192815000 rw-p 00014000 fd:00 1182                           /lib64/libgcc_s-4.6.1-20110908.so.1
    319aa00000-319aae8000 r-xp 00000000 fd:00 265025                         /usr/lib64/libstdc++.so.6.0.16
    319aae8000-319ace8000 ---p 000e8000 fd:00 265025                         /usr/lib64/libstdc++.so.6.0.16
    319ace8000-319acf0000 r--p 000e8000 fd:00 265025                         /usr/lib64/libstdc++.so.6.0.16
    319acf0000-319acf2000 rw-p 000f0000 fd:00 265025                         /usr/lib64/libstdc++.so.6.0.16
    319acf2000-319ad07000 rw-p 00000000 00:00 0
    7fe3fc150000-7fe3fc156000 rw-p 00000000 00:00 0
    7fe3fc173000-7fe3fc175000 rw-p 00000000 00:00 0
    7fe3fc175000-7fe3fc20b000 r-xp 00000000 fd:00 24424978                   /opt/llvm/lib/libc++.so.1.0
    7fe3fc20b000-7fe3fc40b000 ---p 00096000 fd:00 24424978                   /opt/llvm/lib/libc++.so.1.0
    7fe3fc40b000-7fe3fc411000 rw-p 00096000 fd:00 24424978                   /opt/llvm/lib/libc++.so.1.0
    7fe3fc411000-7fe3fc415000 rw-p 00000000 00:00 0
    7fe3fc415000-7fe3fc42d000 r-xp 00000000 fd:00 24424979                   /opt/llvm/lib/libcxxrt.so.1.0
    7fe3fc42d000-7fe3fc62c000 ---p 00018000 fd:00 24424979                   /opt/llvm/lib/libcxxrt.so.1.0
    7fe3fc62c000-7fe3fc62e000 rw-p 00017000 fd:00 24424979                   /opt/llvm/lib/libcxxrt.so.1.0
    7fe3fc62e000-7fe3fc633000 rw-p 00000000 00:00 0
    7fffd355f000-7fffd3580000 rw-p 00000000 00:00 0                          [stack]
    7fffd35ff000-7fffd3600000 r-xp 00000000 00:00 0                          [vdso]
    ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Any ideas what's going on here?

   Matthias



More information about the cfe-dev mailing list