<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - memory sanitizer reports a false positive? with fts code"
   href="http://llvm.org/bugs/show_bug.cgi?id=17267">17267</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>memory sanitizer reports a false positive? with fts code
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>ed0.88.prez@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi. I get this problem when executing this code: 
<a href="https://raw.github.com/rheit/zdoom/master/tools/zipdir/zipdir.c">https://raw.github.com/rheit/zdoom/master/tools/zipdir/zipdir.c</a> compiled with
memory sanitizer:

==30138== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7fdae305ab93 in add_dirs
/home/edward-san/zdoom/trunk/tools/zipdir/zipdir.c:609
    #1 0x7fdae3079227 in main
/home/edward-san/zdoom/trunk/tools/zipdir/zipdir.c:1623
    #2 0x7fdae1dbcea4 in __libc_start_main
/build/buildd/eglibc-2.17/csu/libc-start.c:260
    #3 0x7fdae3057d7c in _start
(/home/edward-san/zdoom/trunk/debug_san/tools/zipdir/zipdir+0x69d7c)
  Uninitialized value was created by a heap allocation
    #0 0x7fdae3026a83 in __interceptor_malloc
/home/edward-san/srcllvm/projects/compiler-rt/lib/msan/msan_interceptors.cc:836
    #1 0x7fdae1e8a56f in fts_alloc /build/buildd/eglibc-2.17/io/fts.c:990
    #2 0x7fdae1e8a56f in fts_open /build/buildd/eglibc-2.17/io/fts.c:143
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/home/edward-san/zdoom/trunk/tools/zipdir/zipdir.c:609 add_dirs
Exiting

I reduced the code to this:

$ cat fts_read_bug.c
#include <fts.h>

int main()
{
    char * const argv[] = {"/usr/local/include", 0};
    FTS *fts;
    FTSENT *ent;

    fts = fts_open(argv, FTS_LOGICAL, 0);

    if (fts == 0)
        return -1;

    ent = fts_read(fts);

    if (ent != 0 &&
        ent->fts_info == FTS_D)
        return 1;

    fts_close(fts);
    return 0;
}

In this case, the message is:
==13273== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f5b6f7899b5 in main /home/edward-san/llvm/fts_read_bug.c:16
    #1 0x7f5b6e916ea4 in __libc_start_main
/build/buildd/eglibc-2.17/csu/libc-start.c:260
    #2 0x7f5b6f7893fc in _start (/home/edward-san/llvm/a.out+0x683fc)
  Uninitialized value was created by a heap allocation
    #0 0x7f5b6f758103 in __interceptor_malloc
/home/edward-san/srcllvm/projects/compiler-rt/lib/msan/msan_interceptors.cc:836
    #1 0x7f5b6e9e456f in fts_alloc /build/buildd/eglibc-2.17/io/fts.c:990
    #2 0x7f5b6e9e456f in fts_open /build/buildd/eglibc-2.17/io/fts.c:143
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/home/edward-san/llvm/fts_read_bug.c:16 main
Exiting

I have no idea of why it happens.</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>