Bug 459827 - CDT does not report the failure when attach fails
Summary: CDT does not report the failure when attach fails
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: Next   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-12 15:30 EST by Simon Marchi CLA
Modified: 2020-09-04 15:20 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Marchi CLA 2015-02-12 15:30:32 EST
On Ubuntu, by default, a process can't attach to another process if it is not in its ptrace scope [1][2].

This is a very common scenario when you are on a fresh Ubuntu install and you haven't disabled the feature. Right now, when trying to attach another process, CDT gives the impression that it worked, but that the process is still running. When looking at the traces, you see:

079,418 18-target-attach --thread-group i1 8940
079,418 18^error,msg="ptrace: Operation not permitted."
079,418 (gdb)

CDT should probably report the failure and abort the launch.

[1] https://wiki.ubuntu.com/Security/Features#ptrace
[2] https://www.kernel.org/doc/Documentation/security/Yama.txt
Comment 1 Marc Khouzam CLA 2015-02-12 15:45:13 EST
A simple way to reproduce something similar is to try to attach to the gdb of the CDT session:

771,012 20-target-attach --thread-group i1 32177&
771,012 20^error,msg="I refuse to debug myself!"

We are not handling such errors nicely and we have a bug or two about this.  This particular error should trigger a popup and abort the session, as Simon mentions.
Comment 2 Marc Khouzam CLA 2015-02-12 16:38:50 EST
The tricky thing about this is that we support connecting to multiple processes in a single user operation, i.e., the user can select multiple processes in the dialog and CDT will attempt to attach to each one.

Right now, if one attach fails, we just ignore it and move on to the next process without reporting an error.  This is also what happens when we fail to attach to a single process.

I think we should (if doable):
1- if attaching to one process and failing, popup an error message
2- if attaching to many processes and failing all, popup an error message
3- if attaching to many and failing some?  Not sure.  There are implications with this one:
    - Do we try to continue attaching after the first failure?
    - What do we do with processes we already attached to?

We also have to think about these attach failure when triggered through a launch or when triggered trough a manual action (pressing the connect button).  Do we want to fail the launch in the first case?  Most probably not for the second case.