Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the logic in DWARFContext thread safety selection (#11) #66786

Closed
wants to merge 2 commits into from

Conversation

kstoimenov
Copy link
Contributor

The patch triggered some TSAN reports. Looks like the logic which decided if the thread safe or thread unsafe implementation should be used is inverted. The test is passing with this patch in place.

The patch triggered some TSAN reports. Looks like the logic which decided if the thread safe or thread unsafe implementation should be used is inverted. The test is passing with this patch in place.
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 19, 2023

@llvm/pr-subscribers-debuginfo

Changes

The patch triggered some TSAN reports. Looks like the logic which decided if the thread safe or thread unsafe implementation should be used is inverted. The test is passing with this patch in place.


Full diff: https://github.com/llvm/llvm-project/pull/66786.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/DWARF/DWARFContext.cpp (+1-1)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index a45ed0e56553d4e..e338a2ebfc9c2c7 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -734,7 +734,7 @@ DWARFContext::DWARFContext(std::unique_ptr<const DWARFObject> DObj,
     : DIContext(CK_DWARF),
       RecoverableErrorHandler(RecoverableErrorHandler),
       WarningHandler(WarningHandler), DObj(std::move(DObj)) {
-        if (ThreadSafe)
+        if (!ThreadSafe)
           State.reset(new ThreadUnsafeDWARFContextState(*this, DWPName));
         else
           State.reset(new ThreadSafeState(*this, DWPName));

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can switch the contents of the if and this is good to go. See inline comment

Comment on lines +737 to 740
if (!ThreadSafe)
State.reset(new ThreadUnsafeDWARFContextState(*this, DWPName));
else
State.reset(new ThreadSafeState(*this, DWPName));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to just invert this if contents:

if (ThreadSafe)
  State.reset(new ThreadSafeState(*this, DWPName));
else
  State.reset(new ThreadUnsafeDWARFContextState(*this, DWPName));

@kstoimenov
Copy link
Contributor Author

Because I am github illiterate I pushed the fix directly into mainline. I will close this PR.

@kstoimenov kstoimenov closed this Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants