This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix cross-platform kills
ClosedPublic

Authored by labath on Nov 4 2021, 5:35 AM.

Details

Summary

This patch fixes an amusing bug where a Platform::Kill operation would
happily terminate a proces on a completely different platform, as long
as they have the same process ID. This was due to the fact that the
implementation was iterating through all known (debugged) processes in
order terminate them directly.

This patch just deletes that logic, and makes everything go through the
OS process termination APIs. While it would be possible to fix the logic
to check for a platform match, it seemed to me that the implementation
was being too smart for its own good -- accessing random Process
objects without knowing anything about their state is risky at best.
Going through the os ensures we avoid any races.

I also "upgrade" the termination signal to a SIGKILL to ensure the
process really dies after this operation.

Diff Detail

Event Timeline

labath requested review of this revision.Nov 4 2021, 5:35 AM
labath created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2021, 5:35 AM
JDevlieghere accepted this revision.Nov 4 2021, 8:50 AM

LGTM

lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
17–27

I always appreciate the elegance of these tests.

This revision is now accepted and ready to land.Nov 4 2021, 8:50 AM
This revision was automatically updated to reflect the committed changes.