llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Don't cause a premature UpdateIfNeeded in SBValue::GetSP

Open jimingham opened this issue 1 year ago • 0 comments

when deciding whether an otherwise invalid SBValue with a useful error should be handed out from GetSP.

This is a follow-on to e8a2fd5e7be2. In that change, I used GetError to check for an error at the beginning of GetSP, before checking for a valid Target or a stopped Process. But GetError calls UpdateIfNeeded. Normally that's not a problem as if there's no valid target or the process is running, somewhere along UpdateIfNeeded the code will realize it can't update and return w/o doing any harm.

But when running lldb in a multithreaded environment (e.g. in Xcode) if you are very unlucky you can get the update to start before you proceed and then just stall waiting to get access to gdb-remote while the process is running.

The change is to add ValueObject::CheckError that returns the error w/o UpdatingIfNeeded, and use that in SBValue::GetSP in the places where we would normally return an invalid SP.

I tried to make a test for this but it's unobservable unless you are very unlucky, and I couldn't figure out a way to be consistently unlucky.

jimingham avatar Dec 08 '23 23:12 jimingham