<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - TestCases/Linux/use_tls_dynamic.cpp fails on CentOS"
   href="https://bugs.llvm.org/show_bug.cgi?id=50446">50446</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>TestCases/Linux/use_tls_dynamic.cpp fails on CentOS
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>lsan
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>bryanpkc@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When build LLVM 12 with GCC 9.3.0, and running "make check-lsan" on CentOS 7, I
see these failures:

  Failed Tests (2):
    LeakSanitizer-AddressSanitizer-x86_64 ::
TestCases/Linux/use_tls_dynamic.cpp
    LeakSanitizer-Standalone-x86_64 :: TestCases/Linux/use_tls_dynamic.cpp

The failing step is this:

  // RUN: %env_lsan_opts=$LSAN_BASE:"use_tls=0" not %run %t 2>&1 | FileCheck %s

It is expecting the sanitizer to detect a memory leak. If I run the command by
hand outside of llvm-lit, it does successfully report a memory leak:

$ env
LSAN_OPTIONS=:detect_leaks=1:"suppressions=:report_objects=1:use_stacks=0:use_registers=0:use_ld_allocations=0:use_tls=0"
$PWD/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp
Test alloc: 0x61a000000600

=================================================================
==46854==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1048576 byte(s) in 1 object(s) allocated from:
    #0 0x40ad05 
(/home/bryanpkc/llvm/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp+0x40ad05)
    #1 0x7fa51ee25f67  (/lib64/ld-linux-x86-64.so.2+0x11f67)
    #2 0x7fa51c7fe713 
(/home/bryanpkc/llvm/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp-so.so+0x713)
    #3 0x42f40b 
(/home/bryanpkc/llvm/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp+0x42f40b)
    #4 0x7fa51db4d3d4  (/lib64/libc.so.6+0x223d4)

Objects leaked above:
0x7fa51c6fe000 (1048576 bytes)

Indirect leak of 1337 byte(s) in 1 object(s) allocated from:
    #0 0x40a5b0 
(/home/bryanpkc/llvm/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp+0x40a5b0)
    #1 0x42f3f7 
(/home/bryanpkc/llvm/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp+0x42f3f7)
    #2 0x7fa51db4d3d4  (/lib64/libc.so.6+0x223d4)

Objects leaked above:
0x61a000000600 (1337 bytes)

SUMMARY: LeakSanitizer: 1049913 byte(s) leaked in 2 allocation(s).

However, llvm-lit prepends ${LLVM_BINARY_DIR}/bin to the $PATH variable, and
this changes the behaviour of the test:

$ env PATH=$PWD/build/bin:$PATH
LSAN_OPTIONS=:detect_leaks=1:"suppressions=:report_objects=1:use_stacks=0:use_registers=0:use_ld_allocations=0:use_tls=0"
$PWD/build/projects/compiler-rt/test/lsan/X86_64LsanConfig/TestCases/Linux/Output/use_tls_dynamic.cpp.tmp
Test alloc: 0x61a000000600
-----------------------------------------------------
Suppressions used:
  count      bytes template
      1    1048576 *tls_get_addr*
-----------------------------------------------------

The test case itself does not use $PATH or invokes any subprocess, and it isn't
obvious how $PATH affect LSAN here.

The problem is not reproducible on Ubuntu 18.04.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>