compnerd / compnerd/ds2

`SIGSEGV` when lldb `eval` executes code in the inferior

Open
#178 0 comments 0 reactions 1 assignee Claimed by @andrurogerz View on GitHub
Dominant language
C++
Stars
20
Forks
4
PR merge metrics
No merged PRs in 30d

Description

There are two lldb test cases that consistently fail when run against ds2 on Linux and Android:
```
TestStateAfterExpression.TestStopReasonAfterExpression.test_thread_state_after_expr_dwarf
TestStateAfterExpression.TestStopReasonAfterExpression.test_thread_state_after_expr_dwo
TestExpressionInSyscall.ExprSyscallTestCase.test_setpgid_dwarf
TestExpressionInSyscall.ExprSyscallTestCase.test_setpgid_dwo
```
The failure log from the test indicates there was an unexpected `SIGSEGV` signal in the inferior:
```
======================================================================
FAIL: test_setpgid_dwarf (TestExpressionInSyscall.ExprSyscallTestCase.test_setpgid_dwarf)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/andrew/src/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1769, in test_method
return attrvalue(self)
^^^^^^^^^^^^^^^
File "/home/andrew/src/llvm/llvm-project/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py", line 17, in test_setpgid
self.expr_syscall()
File "/home/andrew/src/llvm/llvm-project/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py", line 68, in expr_syscall
self.expect_expr("(int)getpid()", result_value=str(process.GetProcessID()))
File "/home/andrew/src/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2525, in expect_expr
value_check.check_value(self, eval_result, str(eval_result))
File "/home/andrew/src/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 299, in check_value
test_base.assertSuccess(val.GetError())
File "/home/andrew/src/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2560, in assertSuccess
self.fail(self._formatMessage(msg, "'{}' is not success".format(error)))
AssertionError: 'error: Execution was interrupted, reason: signal SIGSEGV.
The process has been returned to the state before expression evaluation.
' is not success
Config=x86_64-/home/andrew/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
```
The common behavior of these test cases is that they issue an lldb `eval` command that executes code in the inferior process. The issue can be reproduced without running the tests by issuing `eval` command while attached to any debug target with a command that has to execute code such as `(int)getpid()` or '(int) printf("Hello\\n")'. However, it only fails if the process is in a certain state. If you just break at `main` and run the `eval` call, it won't happen. But if you interrupt a process with `ctrl-C` while threads are blocked in a syscall, the issue does repro. Most likely there's an issue with register save/restore, which is hinted at by this `PTRACE_REGSET` failure that is logged in the ds2 output (when run with with `-d`):
```
[367667][long int ds2::Host::POSIX::PTrace::wrapPtrace(CommandType, pid_t, AddrType, DataType, int) [with CommandType = __ptrace_request; AddrType = int; DataType = iovec*; pid_t = int]] DEBUG : ran ptrace command PTRACE_SETREGSET on pid 367671, returned EFAULT
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.