llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.32k stars 11.69k forks source link

[LLDB] Duplicated FieldDecl #93141

Open asavonic opened 4 months ago

asavonic commented 4 months ago

I stumbled across a bug where a FieldDecl is duplicated in a C++ record. The decl name and type are identical, but addresses are different. LLDB and Clang don't account for this, and Clang crashes during layout computation later. I don't have a short reproducer for this issue yet. LLDB seems to crash only when there is a certain sequence of separate expression evaluations.

However, there used to be a patch D102993 that fixed a similar issue, but it was reverted in D113449. The original test seems to be valid, but it was disabled in the revert, and it still is:

lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py:
class TestCase(TestBase):
    @unittest.expectedFailure  # The fix for this was reverted due to llvm.org/PR52257
    def test(self):
        self.build()
        self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
        test_var = self.expect_expr("test_var", result_type="In")
        nested_member = test_var.GetChildMemberWithName("NestedClassMember")
        self.assertEqual("Outer::NestedClass", nested_member.GetType().GetName())

@rupprecht, @Teemperor, do you know what happened with D102993 after the revert? Can you confirm that the test from the patch is indeed valid?

llvmbot commented 4 months ago

@llvm/issue-subscribers-lldb

Author: Andrew Savonichev (asavonic)

I stumbled across a bug where a FieldDecl is duplicated in a C++ record. The decl name and type are identical, but addresses are different. LLDB and Clang don't account for this, and Clang crashes during layout computation later. I don't have a short reproducer for this issue yet. LLDB seems to crash only when there is a certain sequence of separate expression evaluations. However, there used to be a patch [D102993](https://reviews.llvm.org/D102993) that fixed a similar issue, but it was reverted in [D113449](https://reviews.llvm.org/D113449). The original test seems to be valid, but it was disabled in the revert, and it still is: ``` lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py: class TestCase(TestBase): @unittest.expectedFailure # The fix for this was reverted due to llvm.org/PR52257 def test(self): self.build() self.dbg.CreateTarget(self.getBuildArtifact("a.out")) test_var = self.expect_expr("test_var", result_type="In") nested_member = test_var.GetChildMemberWithName("NestedClassMember") self.assertEqual("Outer::NestedClass", nested_member.GetType().GetName()) ``` @rupprecht, @Teemperor, do you know what happened with D102993 after the revert? Can you confirm that the test from the patch is indeed valid?