<html>
    <head>
      <base href="https://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 --- - libFuzzer fails to load corpus if filesystem does not provide d_type"
   href="https://llvm.org/bugs/show_bug.cgi?id=25991">25991</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libFuzzer fails to load corpus if filesystem does not provide d_type
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jack.lloyd@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With latest (trunk) libFuzzer I ran into a problem fuzzing processes on my
desktop machine. Running the fuzzer against a corpus directory, it would
repeatedly show no units loaded even though it was saving finds to the same
directory. 

It turned out to be due to this loop in FuzzerIO.cpp

  while (auto E = readdir(D)) {
    if (E->d_type == DT_REG || E->d_type == DT_LNK)
      V.push_back(E->d_name);
  }

The Linux man page says d_type is not set for some filesystems, this apparently
includes XFS when running over dm-crypt. This caused this loop to appear to
load the corpus but actually silently skip all the files provided.

I fixed it locally by adding to this loop (from memory here):

else if(E->d_type == DT_UNKNOWN && strcmp(E->d_name, ".") != 0 &&
strcmp(E->d_name, "..") != 0)
  V.push_back(E->d_name);

at which point I could stop and restart my fuzzers and everything seemed to
work.

Let me know if there is any additional information I can provide, and thanks
for a great piece of software.</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>