This is an archive of the discontinued LLVM Phabricator instance.

[Windows, Process] Fix an issue in windows thread handling that was causing LLDB to hang
ClosedPublic

Authored by stella.stamenova on May 17 2018, 10:12 AM.

Details

Summary

The function ResumeThread on Windows returns a DWORD which is an unsigned int. In TargetThreadWindows::DoResume, there's code that determines how many times to call ResumeThread based on whether the return value is greater than 0. Since the function returns -1 (as an unsigned int) on failure, this was getting stuck in an infinite loop if ResumeThread failed for any reason. The correct thing to do is check whether the return value is -1 and then return the appropriate error instead of ignoring the return value.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner added inline comments.May 17 2018, 10:22 AM
source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
127–128 ↗(On Diff #147344)

Can you move this check inside the loop and then remove the additional check from the while condition?

Also, can you write == (DWORD)-1 or == 0xFFFFFFFF instead of == -1? It's the same meaning, but it makes it slightly clearer to the reader that this is intentional.

stella.stamenova marked an inline comment as done.
zturner accepted this revision.May 17 2018, 2:31 PM

Ahh it looks like you attached the updated patch directly to this email instead of updating it through Phabricator. If you can updated it through the Phabricator UI it's more helpful since it updates the graphical diff viewer that way. Otherwise have to open the patch in a separated text editor.

In any case, lgtm.

This revision is now accepted and ready to land.May 17 2018, 2:31 PM

I used Phabricator, actually, I am not sure why it came out differently.

Yea, was just user error on my part. I was looking at the wrong thing.

This revision was automatically updated to reflect the committed changes.