0

Clang++'s leak sanitizer claims I have a memory leak in one of my unit tests. I'm inclined to believe it, but I can't find it by inspection.

I'm compiling with the following options:

/usr/bin/clang++ -std=c++14 -g -Wall -Wextra -pedantic -O0 -fuse-ld=gold -fsanitize=address

I get output looking like

=================================================================
==8611==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x54a650  (~/tmp/tests/utest-...+0x54a650)
    #1 0x61bfc9  (~/tmp/tests/utest-...+0x61bfc9)
    #2 0x55242f  (~/tmp/tests/utest-...+0x55242f)
    #3 0x550a01  (~/tmp/tests/utest-...+0x550a01)
    #4 0x54f928  (~/tmp/tests/utest-...+0x54f928)
    #5 0x5706fa  (~/tmp/tests/utest-...+0x5706fa)
    #6 0x55b8d9  (~/tmp/tests/utest-...+0x55b8d9)
    #7 0x5e0914  (~/tmp/tests/utest-...+0x5e0914)
    #8 0x5deae8  (~/tmp/tests/utest-...+0x5deae8)
    #9 0x5c8bde  (~/tmp/tests/utest-...+0x5c8bde)
    #10 0x5b23fa  (~/tmp/tests/utest-...+0x5b23fa)
    #11 0x5a1ee9  (~/tmp/tests/utest-...+0x5a1ee9)
    #12 0x56dcdf  (~/tmp/tests/utest-...+0x56dcdf)
    #13 0x566d57  (~/tmp/tests/utest-...+0x566d57)
    #14 0x7f9fb622e60f  (/usr/lib/libc.so.6+0x2060f)

(with unimportant information removed).

The problem with the above output is that I get memory addresses instead of file and line numbers so that I can figure out what is being leaked!

According to Chandler Carruth of Clang at Google fame, enabling debugging output ('-g') should cause the memory addresses in the stack trace to be replaced by file and line numbers. (You can specifically see him apply that here.) As you can see from my compile flags, I am emitting debug info.

Any idea what I may be neglecting?

Timtro
  • 418
  • 5
  • 15
  • This not help http://stackoverflow.com/questions/21163828/meaningful-stack-traces-for-address-sanitizer-in-gcc ? – fghj Nov 09 '15 at 22:19
  • @user1034749 Thanks! I ignored posts like this since they talked about GCC. I hadn't realized that GCC uses clang on the back end to implement its sanitization. If you want to write an answer, I'll accept it. In my case, I needed to install the full llvm Arch Linux package, which includes llvm-symbolizer. – Timtro Nov 10 '15 at 02:02
  • No, `I hadn't realized that GCC uses clang on the back end` it is not true, just people from google implement for both clang and gcc the same functionality, because of that they very similar, but it is not true that gcc uses clang or clang uses gcc. I mark it as duplicate. – fghj Nov 10 '15 at 02:05

0 Answers0