<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 - LLD + -fsanitize=address segfaults in scandir."
   href="https://bugs.llvm.org/show_bug.cgi?id=37303">37303</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD + -fsanitize=address segfaults in scandir.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jeanmichael.celerier@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,

the following fails when compiled with -fsanitize=address -fuse-ld=lld : 

bug.c: 

    #include <dirent.h>
    #include <fcntl.h>

    int filter(const struct dirent *dirent) { return 0; }
    int main() {
      struct dirent **namelist;
      scandir("/usr/lib", &namelist, filter, versionsort);
    }

    $ clang -D_GNU_SOURCE -O0 foo.c -fsanitize=address -fuse-ld=lld
    $ ./a.out


    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==23603==ERROR: AddressSanitizer: SEGV on unknown address 0x0000fffd2f8a
(pc 0x55bd8515b3b3 bp 0x7ffecc9d0cd0 sp 0x7ffecc9d0450 T0)
    ==23603==The signal is caused by a WRITE memory access.
        #0 0x55bd8515b3b2 in __interceptor_scandir.part.106
(/tmp/a.out+0xa73b2)
        #1 0x55bd85201c5e in main (/tmp/a.out+0x14dc5e)
        #2 0x7fb2e5c819a6 in __libc_start_main (/usr/lib/libc.so.6+0x219a6)
        #3 0x55bd85105029 in _start (/tmp/a.out+0x51029)

It works fine with -fuse-ld=gold/bfd</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>