[all-commits] [llvm/llvm-project] fb17bc: [lldb][Linux] Fix checking of error values when at...

David Spickett via All-commits all-commits at lists.llvm.org
Tue Oct 7 01:42:12 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb17bc70acd77f1799ee64f6d2a21d8df2944b5a
      https://github.com/llvm/llvm-project/commit/fb17bc70acd77f1799ee64f6d2a21d8df2944b5a
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2025-10-07 (Tue, 07 Oct 2025)

  Changed paths:
    M lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp

  Log Message:
  -----------
  [lldb][Linux] Fix checking of error values when attach fails (#161673)

Relates to #161510

Fixes 6db44e52ce474bbeb66042073a6e3c6c586f78a2

(it's not fixing it, it's just making the error not be an unhandled
error)

When we fail to attach to a process we see if we can add more
information about why it happened:
```
  if (status.GetError() == EPERM) {
    // Depending on the value of ptrace_scope, we can return a different
    // error that suggests how to fix it.
    return AddPtraceScopeNote(status.ToError());
  }
```
ToError creates a new error value and leaves the one in `status`
unchecked. `status`'s error is ok because it will be checked by Status'
destructor.

The problem happens in `AddPtraceScopeNote`. If we take certain return
paths, this new error, or the one we get when trying to find the ptrace
scope, may be unchecked on destruction when the function returns.

To fix this, in AddPtraceScopeNote, consume any errors that we are not
going to return. Anything returned will be checked by some caller.

Reproducing this failure mode is difficult but it can be faked by
calling AddPtraceScopeNote earlier. Which is what I did to prove the
concept of the problem.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list