<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 - no warning when standalone debug file does not match"
   href="https://bugs.llvm.org/show_bug.cgi?id=33156">33156</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>no warning when standalone debug file does not match
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>emaste@freebsd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I was testing a FreeBSD upgrade in a chroot and sh segfaulted. When examining
the core lldb opens /usr/lib/debug/bin/sh.debug, not the one in the chroot dir;
this is as expected. However, it provides no warning or error that the .debug
file does not match the binary.

For example:

root@nuc:/nroot # lldb bin/sh -c sh.core
(lldb) target create "bin/sh" --core "sh.core"
Core file '/nroot/sh.core' (x86_64) was loaded.
(lldb) bt
* thread #1, name = 'sh', stop reason = signal SIGABRT
  * frame #0: 0x0000007640cb66ca libc.so.7`___lldb_unnamed_symbol480$$libc.so.7
+ 26
    frame #1: 0x0000007640cb65f0 libc.so.7`___lldb_unnamed_symbol476$$libc.so.7
+ 48
    frame #2: 0x0000007640d071be libc.so.7`__res_nsend + 126
(lldb) image list
[  0] F8ED646E-0000-0000-0000-000000000000                    /nroot/bin/sh 
[  1] F12453D1-0000-0000-0000-000000000000                    /bin/sh 
      /usr/lib/debug/bin/sh.debug
[  2] 8B7D0D02-0000-0000-0000-000000000000                    /lib/libedit.so.7 
[  3] 4118A645-0000-0000-0000-000000000000                    /lib/libc.so.7 
[  4] 33FC476C-0000-0000-0000-000000000000                   
/lib/libncursesw.so.8 
[  5] 34772837-0000-0000-0000-000000000000                   
/libexec/ld-elf.so.1 
      /usr/lib/debug/libexec/ld-elf.so.1.debug

gdb's behaviour seems sensible, providing warnings for (some of) these cases:

root@nuc:/nroot # gdb7121 bin/sh sh.core
GNU gdb (GDB) 7.12.1 [GDB v7.12.1 for FreeBSD]
Copyright (C) 2017 Free Software Foundation, Inc.
...
warning: .dynamic section for "/lib/libedit.so.7" is not at the expected
address (wrong library or version mismatch?)

warning: .dynamic section for "/lib/libncursesw.so.8" is not at the expected
address (wrong library or version mismatch?)

warning: .dynamic section for "/libexec/ld-elf.so.1" is not at the expected
address (wrong library or version mismatch?)

warning: the debug information found in
"/usr/lib/debug//lib/libedit.so.7.debug" does not match "/lib/libedit.so.7"
(CRC mismatch).

warning: the debug information found in "/usr/lib/debug//lib/libc.so.7.debug"
does not match "/lib/libc.so.7" (CRC mismatch).

warning: the debug information found in
"/usr/lib/debug//lib/libncursesw.so.8.debug" does not match
"/lib/libncursesw.so.8" (CRC mismatch).</pre>
        </div>
      </p>


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

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>