[llvm-bugs] [Bug 48434] New: attribute instantiation for class template specializations can lead to deserialization cycles

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 7 15:53:54 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48434

            Bug ID: 48434
           Summary: attribute instantiation for class template
                    specializations can lead to deserialization cycles
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Consider:

```
template<typename T> struct A;
using X = A<int>;
template<typename T> struct [[attr(X)]] A {};
X x;
```

Now, deserializing `x` crashes, because it hits a cycle:

* Deserializing `x` reads the TypedefNameDecl `X`
* Deserializing `X` reads its RecordType `A<int>`
* Deserializing `A<int>` reads its attributes
* Deserializing `attr(X)` finds we already have an `X`, so tries to use it
* Using the `X` to form a `TypedefType` crashes, because `X` is not
sufficiently initialized

This is broken because we violated the deserialization invariant by emitting
bitcode for `X` that (indirectly) refers to a lexically-later part of the
program, specifically the attributes for `A<int>`.

To fix this, I think we need to lazily load attributes, at least for template
specializations.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201207/7350ed0c/attachment.html>


More information about the llvm-bugs mailing list