This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix dead lock issue when loading modules in Scripted Process
ClosedPublic

Authored by mib on Jul 6 2023, 1:09 PM.

Details

Summary

This patch attempts to fix a dead lock when loading modules in a Scripted
Process.

This issue was triggered by loading the modules after the process did resume,
but before the process actually stop, causing the language runtime mutex to
be locked by a separate thread, responsible to unwind the stack (using
the runtime unwind plan), while the module loading thread was trying to
notify the runtimes of the newly loaded module.

To address that, this patch moves the module loading logic to be done before
sending the stop event, to prevent the dead lock situation described above.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Diff Detail

Event Timeline

mib created this revision.Jul 6 2023, 1:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 1:09 PM
mib requested review of this revision.Jul 6 2023, 1:09 PM
jingham accepted this revision.Jul 6 2023, 1:23 PM

Yes, that makes sense. lldb always updates its shared library state in reaction to a stop, so it's much safer to have the scripted process emulate this behavior. Plus, refreshing the state for a given stop makes more sense in the place where you generate the stop, than it does in the place where you tell yourself you've resumed.

This revision is now accepted and ready to land.Jul 6 2023, 1:23 PM
JDevlieghere accepted this revision.Jul 6 2023, 1:29 PM

LGTM. Might be worth adding a little comment there to make sure we remember why the check is there in the future.