<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 - Multiple inconsistent FDEs covering the same code addresses"
   href="https://bugs.llvm.org/show_bug.cgi?id=47148">47148</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Multiple inconsistent FDEs covering the same code addresses
          </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>wittman@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang is emitting multiple FDEs that overlap the same code addresses and these
FDEs contain conflicting unwind information.

This was observed in Chromium's clang built from
1bd7046e4ce0102adef6096a12a289d7f94b8c73.

In the repro case below only one function is in the output, but the compiler
emits four FDEs of unwind instructions. All four overlap in the address range
0x0..0x10. The fourth FDEs has conflicting instructions for address 0x4
compared to the other three. The third FDE has conflicting instructions for
address 0x8 compared to the first and second, and the fourth.

test.cc:
template <class Tp>
struct compressed_pair {
  constexpr compressed_pair() : value() {}
  Tp value;
};

struct basic_string
{
  enum { n_words = 10 };

  struct raw {
    int words[n_words];
  };

  compressed_pair<raw> r;

  basic_string();

  void zero() {
    for (unsigned i = 0; i < n_words; ++i)
      r.value.words[i] = 0;
  }
};
inline basic_string::basic_string() { zero(); }

void foo() {
  basic_string s;
}

$ clang++ -target arm-linux-androideabi16 -g -funwind-tables
-fomit-frame-pointer -c test.cc -o test.o

$ objdump -j .text -dC test.o

test.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <foo()>:
   0:   e92d4800        push    {fp, lr}
   4:   e24dd028        sub     sp, sp, #40     ; 0x28
   8:   e1a0000d        mov     r0, sp
   c:   ebfffffe        bl      0 <foo()>
  10:   e28dd028        add     sp, sp, #40     ; 0x28
  14:   e8bd4800        pop     {fp, lr}
  18:   e12fff1e        bx      lr

$ llvm-dwarfdump --debug-frame test.o

test.o: file format ELF32-arm-little

.debug_frame contents:

00000000 00000010 ffffffff CIE
  Version:               4
  Augmentation:          ""
  Address size:          4
  Segment desc size:     0
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 14

  DW_CFA_def_cfa: reg13 +0
  DW_CFA_nop:
  DW_CFA_nop:

00000014 00000018 00000000 FDE cie=00000000 pc=00000000...0000001c
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +8
  DW_CFA_offset: reg14 -4
  DW_CFA_offset: reg11 -8
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +48
  DW_CFA_nop:
  DW_CFA_nop:

00000030 00000018 00000000 FDE cie=00000000 pc=00000000...00000030
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +8
  DW_CFA_offset: reg14 -4
  DW_CFA_offset: reg11 -8
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +16
  DW_CFA_nop:
  DW_CFA_nop:

0000004c 00000018 00000000 FDE cie=00000000 pc=00000000...0000002c
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +8
  DW_CFA_offset: reg14 -4
  DW_CFA_offset: reg11 -8
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +16
  DW_CFA_nop:
  DW_CFA_nop:

00000068 00000010 00000000 FDE cie=00000000 pc=00000000...00000058
  DW_CFA_advance_loc: 4
  DW_CFA_def_cfa_offset: +12
  DW_CFA_nop:

.eh_frame contents:</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>