[PATCH] D18849: [modules] Avoid module relocation error when building modules from VFS

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 17:15:57 PDT 2016


bruno created this revision.
bruno added reviewers: rsmith, benlangmuir, klimek.
bruno added subscribers: aprantl, dexonsmith, cfe-commits.

The reproducer script (generated by the crash reproducer) invokes clang
and tries to rebuild modules using the headers in the .cache/vfs
directory. Depending on the order that modules are constructed it is
possible that there's a mismatch between the directory that a module was
constructed and the path that it was found:

fatal error: module '_Builtin_stddef_max_align_t' was built in directory
'/Users/bruno/Dev/install/clang/bin/../lib/clang/<ver>/include'
but now resides in directory
'/<path_to>.cache/vfs/Users/bruno/Dev/install/clang/lib/clang/<ver>/include'

This happens because getFile() can leak the original path depending on
the way it's accessed. This seems to be known issue and one that demands
a lot of work to get rid of, according to:

  [cfe-dev] Module maps, __FILE__ and lazy stat'ing of header
  http://lists.llvm.org/pipermail/cfe-dev/2014-July/038273.html

I tried a couple of fixes to the issue but this is the less invasive I
could come up with. This fixes the issue by first looking into modules
by using virtual dir paths instead of the real ones. Let me know if
there's a better solution or whether I'm missing something.

With this change on Darwin we are able to simulate a crash for a simple
application using "Foundation/Foundation.h" (which relies on a bunch of
different frameworks and headers) and successfully rebuild all the
modules by relying solely at the VFS overlay.

http://reviews.llvm.org/D18849

Files:
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/crash-recovery/Users/bar/a.h
  test/Modules/Inputs/crash-recovery/Users/bar/bar.h
  test/Modules/Inputs/crash-recovery/Users/bar/module.modulemap
  test/Modules/Inputs/crash-recovery/Users/foo/foo.h
  test/Modules/Inputs/crash-recovery/Users/foo/module.modulemap
  test/Modules/crash-vfs-module-redefinition.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18849.52873.patch
Type: text/x-patch
Size: 4941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160407/d7302644/attachment.bin>


More information about the cfe-commits mailing list