[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 18:02:28 PST 2017


According to the comment at line 239:

    if (LoadedSuccessfully.count(*victim) == 0) {
      // Before removing the module file, check if it was validated in an
      // ancestor thread, if yes, throw a hard error instead of causing
      // use-after-free in the ancestor thread.
      bool IsSystem;
      if (FileMgr.getPCMCache()->isValidatedByAncestor((*victim)->FileName,
                                                       IsSystem))
        ValidationConflicts.push_back((*victim)->FileName);
      else
        FileMgr.invalidateCache((*victim)->File);
      FileMgr.getPCMCache()->removeFromConsistentBuffer((*victim)->FileName);
    }

that looks like it would cause a use-after-free in the parent thread.  What am I missing?

> On 2017-Jan-24, at 17:56, Bruno Cardoso Lopes via Phabricator <reviews at reviews.llvm.org> wrote:
> 
> bruno added inline comments.
> 
> 
> ================
> Comment at: lib/Serialization/ASTReader.cpp:3692
> +                            ValidationConflicts);
> +    for (auto N : ValidationConflicts)
> +      Diag(diag::err_module_ancestor_conflict) << N;
> ----------------
> This should honor `ARR_OutOfDate`, so that the module can be rebuilt in case a user module mismatch via a different diagnostics (lib/Serialization/ASTReader.cpp:4076) and returns OutOfDate instead of Success:
> 
>    if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
>      for (auto N : ValidationConflicts)
>        Diag(diag::err_module_ancestor_conflict) << N;
> 
> 
> https://reviews.llvm.org/D28299
> 
> 
> 



More information about the cfe-commits mailing list