<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 --- - We cannot backtrace out of fflush() on Linux x86_64"
   href="https://llvm.org/bugs/show_bug.cgi?id=27687">27687</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>We cannot backtrace out of fflush() on Linux x86_64
          </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>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>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>labath@google.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>This is happening in TestPrintStackTraces, where we can end up here:
ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2:
    0x7ffff7df04e0 <+0>:  48 83 ec 38                                   subq  
$0x38, %rsp
    0x7ffff7df04e4 <+4>:  48 89 04 24                                   movq  
%rax, (%rsp)
    0x7ffff7df04e8 <+8>:  48 89 4c 24 08                                movq  
%rcx, 0x8(%rsp)
    0x7ffff7df04ed <+13>: 48 89 54 24 10                                movq  
%rdx, 0x10(%rsp)
    0x7ffff7df04f2 <+18>: 48 89 74 24 18                                movq  
%rsi, 0x18(%rsp)
    0x7ffff7df04f7 <+23>: 48 89 7c 24 20                                movq  
%rdi, 0x20(%rsp)
    0x7ffff7df04fc <+28>: 4c 89 44 24 28                                movq  
%r8, 0x28(%rsp)
    0x7ffff7df0501 <+33>: 4c 89 4c 24 30                                movq  
%r9, 0x30(%rsp)
    0x7ffff7df0506 <+38>: 48 8b 74 24 40                                movq  
0x40(%rsp), %rsi
    0x7ffff7df050b <+43>: 48 8b 7c 24 38                                movq  
0x38(%rsp), %rdi
    0x7ffff7df0510 <+48>: e8 4b 8f ff ff                                callq 
0x7ffff7de9460            ; ___lldb_unnamed_symbol54$$ld-linux-x86-64.so.2
    0x7ffff7df0515 <+53>: 49 89 c3                                      movq  
%rax, %r11
    0x7ffff7df0518 <+56>: 4c 8b 4c 24 30                                movq  
0x30(%rsp), %r9
    0x7ffff7df051d <+61>: 4c 8b 44 24 28                                movq  
0x28(%rsp), %r8
    0x7ffff7df0522 <+66>: 48 8b 7c 24 20                                movq  
0x20(%rsp), %rdi
    0x7ffff7df0527 <+71>: 48 8b 74 24 18                                movq  
0x18(%rsp), %rsi
    0x7ffff7df052c <+76>: 48 8b 54 24 10                                movq  
0x10(%rsp), %rdx
    0x7ffff7df0531 <+81>: 48 8b 4c 24 08                                movq  
0x8(%rsp), %rcx
->  0x7ffff7df0536 <+86>: 48 8b 04 24                                   movq  
(%rsp), %rax
    0x7ffff7df053a <+90>: 48 83 c4 48                                   addq  
$0x48, %rsp
    0x7ffff7df053e <+94>: 41 ff e3                                      jmpq  
*%r11
    0x7ffff7df0541 <+97>: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00  nopw  
%cs:(%rax,%rax)


image show-unwind --address 0x7ffff7df0536
UNWIND PLANS for
ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2 (start addr
0x7ffff7df04e0)

Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly insn
profiling'
Synchronous (restricted to call-sites) UnwindPlan is 'eh_frame CFI'

Assembly language inspection UnwindPlan:
This UnwindPlan originally sourced from assembly insn profiling
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: yes.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text +
88576-0x0000000000015a70)
row[0]:    0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8] 
row[1]:    4: CFA=rsp+64 => rsp=CFA+0 rip=[CFA-8] 
row[2]:   94: CFA=rsp -8 => rsp=CFA+0 rip=[CFA-8] 

eh_frame UnwindPlan:
This UnwindPlan originally sourced from eh_frame CFI
This UnwindPlan is sourced from the compiler: yes.
This UnwindPlan is valid at all instruction locations: no.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text +
88576-0x0000000000015a61)
row[0]:    0: CFA=rsp+24 => rip=[CFA-8] 
row[1]:    4: CFA=rsp+80 => rip=[CFA-8] 
row[2]:   94: CFA=rsp +8 => rip=[CFA-8] 


So the, eh_frame unwind plan is actually correct, but we are using the assembly
emulation unwind plan, which ends up being hopelessly incorrect, as the
function we are in does not have a normal stack frame (it exits via a tail
call, and I think it is entered by one as well). The unwind machinery
eventually picks itself up, but not before skipping a couple of frames on the
stack.

We should find a way to get lldb to use eh_frame plan (or
eh_frame+augmentation) here.</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>