This is an archive of the discontinued LLVM Phabricator instance.

Make it possible to stop the operation thread in NativeProcessLinux
ClosedPublic

Authored by tberghammer on Feb 27 2015, 5:35 AM.

Details

Summary

Make it possible to stop the operation thread in NativeProcessLinux

Previously the operation thread is stopped with a cancel event but pthread_cancel is not supported on android. This CL creates a custom operation which asks the operation thread to exit without any pthread call.

Diff Detail

Repository
rL LLVM

Event Timeline

tberghammer retitled this revision from to Make it possible to stop the operation thread in NativeProcessLinux.
tberghammer updated this object.
tberghammer edited the test plan for this revision. (Show Details)
tberghammer added reviewers: vharron, ovyalov.
tberghammer added a subscriber: Unknown Object (MLST).
emaste added a subscriber: emaste.Feb 27 2015, 6:56 AM

I think it's worth adding a comment in the source explaining why .Cancel() is not used.

ovyalov accepted this revision.Feb 27 2015, 11:10 AM
ovyalov edited edge metadata.

Looks good - please address suggestions before submitting.

source/Plugins/Process/Linux/NativeProcessLinux.cpp
3566 ↗(On Diff #20846)

Could you also swap StopOpThread() and StopCoordinatorThread ()?
If there there are en-queued and/or active commands in TSC thread that need PTRACE they will deadlock on DoOperation since operation thread has been stopped.

This revision is now accepted and ready to land.Feb 27 2015, 11:10 AM
This revision was automatically updated to reflect the committed changes.
ovyalov added inline comments.Mar 2 2015, 6:12 PM
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
3568

Actually, I meant such sequence:

StopMonitoringChildProcess(); // en-queues PTRACE & TSC commands 
StopCoordinatorThread (); // en-queues PTRACE commands
StopOpThread();

In this case, StopOpThread is executed when there is nobody around who can issue a PTRACE request.

This CL seems to make deadlock on TestAttachDenied.py - DoOperation(nullptr) is blocked on "while (sem_wait(&m_operation_done))" because attach operation failed and operation thread has exited already. I assume the issue is also happening if launch fails. If attach/launch fails we need just join without calling DoOperation.

Thanks for pointing out the deadlock.
Address both issue with D8030.