[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-bugs
Subject:    [llvm-bugs] [Bug 50948] New: LLDB not clearing EXC_BAD_ACCESS exception after `thread return` (on Ma
From:       via llvm-bugs <llvm-bugs () lists ! llvm ! org>
Date:       2021-06-30 17:30:26
Message-ID: bug-50948-206 () http ! bugs ! llvm ! org/
[Download RAW message or body]

--1625074226.6c887ee0.11538
Date: Wed, 30 Jun 2021 10:30:26 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated

https://bugs.llvm.org/show_bug.cgi?id=50948

            Bug ID: 50948
           Summary: LLDB not clearing EXC_BAD_ACCESS exception after
                    `thread return` (on MacOS)?
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev@lists.llvm.org
          Reporter: vyng@google.com
                CC: jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

Repro:

Using the following test code:

// bad_access.cc
     1  // bad_access.cc
     2  #include <stdio.h>
     3  #include <stdlib.h>
     4  
     5  int bad_acc(void){
     6    printf("in bad_acc()\n");
     7    
     8    // cause bad mem access here
     9    return *(int*)(123);
    10  }
    11  
    12  int main () {
    13    printf( "hello world\n");
    14    // bad access here
    15    bad_acc();
    16    printf("bye world\n");
    17    return 0;
    18  }
vyng-macbookpro2% 
// Compile and run with lldb:

% clang -g -o bad_acc bad_access.cc
% lldb
(lldb) target create "bad_acc"
Current executable set to '<path_to>/bad_acc' (x86_64).
(lldb) 
Current executable set to '<path_to>/bad_acc' (x86_64).
(lldb) run
Process 97548 launched: '<path_to>/bad_acc' (x86_64)
hello world
in bad_acc()
Process 97548 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
    frame #0: 0x0000000100003f0b bad_acc`bad_acc() at bad_access.cc:9:10
   6      printf("in bad_acc()\n");
   7      
   8      // cause bad mem access here
-> 9      return *(int*)(123);
   10   }
   11   
   12   int main () {
Target 1: (bad_acc) stopped.
(lldb) thread return
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
    frame #0: 0x0000000100003f45 bad_acc`main at bad_access.cc:16:3
   13     printf( "hello world\n");
   14     // bad access here
   15     bad_acc();
-> 16     printf("bye world\n");
   17     return 0;
   18   }
(lldb) register write pc `$pc-8`
(lldb) register write pc `$pc-8`
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
  * frame #0: 0x0000000100003f35 bad_acc`main at bad_access.cc:13:3
    frame #1: 0x00007fff204e8f5d libdyld.dylib`start + 1
    frame #2: 0x00007fff204e8f5d libdyld.dylib`start + 1
(lldb) n
Process 97548 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x27e80d)
    frame #0: 0x0000000100003f35 bad_acc`main at bad_access.cc:13:3
   10   }
   11   
   12   int main () {
-> 13     printf( "hello world\n");
   14     // bad access here
   15     bad_acc();
   16     printf("bye world\n");
Target 1: (bad_acc) stopped.


------------------------------------------

Details:

After the processed stopped on bad_access.cc:9, I used `thread return` and two
`register write pc `$pc-8`` hoping to get back to bad_access.cc:13 to restart
the exececution.

- Expected behaviour: the exception is cleared and the program restarted.
- What actually happened: exception didn't clear and the program failed to
continue. (Even though `bt` showed that we were now back to line 13).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
--1625074226.6c887ee0.11538
Date: Wed, 30 Jun 2021 10:30:26 -0700
MIME-Version: 1.0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated

<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 - LLDB not clearing EXC_BAD_ACCESS exception after `thread return` (on MacOS)?"
   href="https://bugs.llvm.org/show_bug.cgi?id=50948">50948</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB not clearing EXC_BAD_ACCESS exception after `thread return` (on MacOS)?
          </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>MacOS X
          </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&#64;lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vyng&#64;google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere&#64;apple.com, llvm-bugs&#64;lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Repro:

Using the following test code:

// bad_access.cc
     1  // bad_access.cc
     2  #include &lt;stdio.h&gt;
     3  #include &lt;stdlib.h&gt;
     4  
     5  int bad_acc(void){
     6    printf(&quot;in bad_acc()\n&quot;);
     7    
     8    // cause bad mem access here
     9    return *(int*)(123);
    10  }
    11  
    12  int main () {
    13    printf( &quot;hello world\n&quot;);
    14    // bad access here
    15    bad_acc();
    16    printf(&quot;bye world\n&quot;);
    17    return 0;
    18  }
vyng-macbookpro2% 
// Compile and run with lldb:

% clang -g -o bad_acc bad_access.cc
% lldb
(lldb) target create &quot;bad_acc&quot;
Current executable set to '&lt;path_to&gt;/bad_acc' (x86_64).
(lldb) 
Current executable set to '&lt;path_to&gt;/bad_acc' (x86_64).
(lldb) run
Process 97548 launched: '&lt;path_to&gt;/bad_acc' (x86_64)
hello world
in bad_acc()
Process 97548 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
    frame #0: 0x0000000100003f0b bad_acc`bad_acc() at bad_access.cc:9:10
   6      printf(&quot;in bad_acc()\n&quot;);
   7      
   8      // cause bad mem access here
-&gt; 9      return *(int*)(123);
   10   }
   11   
   12   int main () {
Target 1: (bad_acc) stopped.
(lldb) thread return
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
    frame #0: 0x0000000100003f45 bad_acc`main at bad_access.cc:16:3
   13     printf( &quot;hello world\n&quot;);
   14     // bad access here
   15     bad_acc();
-&gt; 16     printf(&quot;bye world\n&quot;);
   17     return 0;
   18   }
(lldb) register write pc `$pc-8`
(lldb) register write pc `$pc-8`
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x7b)
  * frame #0: 0x0000000100003f35 bad_acc`main at bad_access.cc:13:3
    frame #1: 0x00007fff204e8f5d libdyld.dylib`start + 1
    frame #2: 0x00007fff204e8f5d libdyld.dylib`start + 1
(lldb) n
Process 97548 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x27e80d)
    frame #0: 0x0000000100003f35 bad_acc`main at bad_access.cc:13:3
   10   }
   11   
   12   int main () {
-&gt; 13     printf( &quot;hello world\n&quot;);
   14     // bad access here
   15     bad_acc();
   16     printf(&quot;bye world\n&quot;);
Target 1: (bad_acc) stopped.


------------------------------------------

Details:

After the processed stopped on bad_access.cc:9, I used `thread return` and two
`register write pc `$pc-8`` hoping to get back to bad_access.cc:13 to restart
the exececution.

- Expected behaviour: the exception is cleared and the program restarted.
- What actually happened: exception didn't clear and the program failed to
continue. (Even though `bt` showed that we were now back to line 13).</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>
--1625074226.6c887ee0.11538--

[Attachment #3 (text/plain)]

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic