-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[lldb] Fix the semantics of SupportFile equivalence #95606
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
Conversation
Currently, two SupportFiles with the same FileSpec are considered different if one of them has a Checksum and the other doesn't. However, this is overly strict. It's totally valid to mix LineTables that do and do not contain Checksums. This patch makes it so that the Checksum is only compared if both SupportFiles have a valid Checksum.
Credit to @jasonmolenda for uncovering this bug. |
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesCurrently, two SupportFiles with the same FileSpec are considered different if one of them has a Checksum and the other doesn't. However, this is overly strict. It's totally valid to mix LineTables that do and do not contain Checksums. This patch makes it so that the Checksum is only compared if both SupportFiles have a valid Checksum. Full diff: https://github.com/llvm/llvm-project/pull/95606.diff 1 Files Affected:
diff --git a/lldb/include/lldb/Utility/SupportFile.h b/lldb/include/lldb/Utility/SupportFile.h
index 7505d7f345c5d..d65156cea768f 100644
--- a/lldb/include/lldb/Utility/SupportFile.h
+++ b/lldb/include/lldb/Utility/SupportFile.h
@@ -30,8 +30,12 @@ class SupportFile {
virtual ~SupportFile() = default;
+ /// Return true if both SupportFiles have the same FileSpec and, if both have
+ /// a valid Checksum, the Checksum is the same.
bool operator==(const SupportFile &other) const {
- return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
+ if (m_checksum && other.m_checksum)
+ return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
+ return m_file_spec == other.m_file_spec;
}
bool operator!=(const SupportFile &other) const { return !(*this == other); }
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous check does seem overly restrictive.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for coming up with the right fix, this looks good to me.
Thanks for the overwhelming support :-) |
When Jason was looking into the issue caused by llvm#95606 he suggested using the Checksum from the original file in LineEntry. I like the idea because it makes sense semantically, but also allows us to get rid of the Update method and ensures we make a new copy, in case someone else is holding onto the old SupportFile.
I hate to ruin a party, but I don't think this is a good use of |
When Jason was looking into the issue caused by #95606 he suggested using the Checksum from the original file in LineEntry. I like the idea because it makes sense semantically, but also allows us to get rid of the Update method and ensures we make a new copy, in case someone else is holding onto the old SupportFile.
The place I hit a problem with this was in
and only one of the SupportFile's here had a checksum, so the == test failed (and an inlined stepping bug came up) If I read There are probbly some other uses of this operator== and maybe I shouldn't focus on this one, but I'm trying to think of how the intention could be clearly expressed with a method name here. |
I'd be fine with |
I think that This can have implications for this bug as well. I don't know how we can end up in a different line table here, but if that can happen twice, and the middle line table has no checksum, then it can make a difference in whether you compare to the previous line table, or the initial/starting one. (I don't think this is likely to happen, I'm just using it to illustrate the point.) With that in mind, I think Unfortunately, I don't know of a concise way to express this difference, maybe because the concept is not concise to begin with. |
I was thinking about this too, and the best idea I had was |
|
This is an improved attempt to improve the semantics of SupportFile equivalence, taking into account the feedback from llvm#95606. Pavel's comment about the lack of a concise name because the concept isn't trivial made me realize that I don't want to abstract this concept away behind a helper function. Instead, I opted for a rather verbose enum that forces the caller to consider exactly what kind of comparison is appropriate for every call.
This is an improved attempt to improve the semantics of SupportFile equivalence, taking into account the feedback from #95606. Pavel's comment about the lack of a concise name because the concept isn't trivial made me realize that I don't want to abstract this concept away behind a helper function. Instead, I opted for a rather verbose enum that forces the caller to consider exactly what kind of comparison is appropriate for every call.
This is an improved attempt to improve the semantics of SupportFile equivalence, taking into account the feedback from llvm#95606. Pavel's comment about the lack of a concise name because the concept isn't trivial made me realize that I don't want to abstract this concept away behind a helper function. Instead, I opted for a rather verbose enum that forces the caller to consider exactly what kind of comparison is appropriate for every call.
This is an improved attempt to improve the semantics of SupportFile equivalence, taking into account the feedback from llvm#95606. Pavel's comment about the lack of a concise name because the concept isn't trivial made me realize that I don't want to abstract this concept away behind a helper function. Instead, I opted for a rather verbose enum that forces the caller to consider exactly what kind of comparison is appropriate for every call.
Currently, two SupportFiles with the same FileSpec are considered different if one of them has a Checksum and the other doesn't. However, this is overly strict. It's totally valid to mix LineTables that do and do not contain Checksums. This patch makes it so that the Checksum is only compared if both SupportFiles have a valid Checksum.