[cfe-dev] PCH generated in a different environment crashes application

Geoff Levner via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 10 03:17:15 PDT 2018


Well I made my own subclass of VerifyPCHAction that sets
AllowConfigurationMismatch to false, but it makes no difference.
On Wed, 10 Oct 2018 at 08:59, Geoff Levner <glevner at gmail.com> wrote:
>
> Hi Richard,
>
> I don't create an ASTReader, I just use the clang driver with the
> following arguments:
>
>    dg2
>    -x
>    c++
>    <PCH file name>
>    -fsyntax-only
>    -fno-caret-diagnostics
>    -resource-dir
>    <clang resource dir>
>    -std=c++11
>    -O3
>    -Wall
>    -Wextra
>    -Wpedantic
>    -fPIC
>
> (The first argument is the name of our application, I assume it makes
> no difference.) Is there an argument corresponding to
> AllowConfigurationMismatch?
>
> Thanks,
> Geoff
> On Tue, 9 Oct 2018 at 20:56, Richard Smith <richard at metafoo.co.uk> wrote:
> >
> > On Tue, 9 Oct 2018 at 08:17, Geoff Levner via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> >>
> >> We have an application that uses Clang and an Orc-based JIT to compile
> >> and run C++ code on the fly. To speed up compilation, the application
> >> generates a .h file that includes all the required header files, then
> >> precompiles it to a PCH file. So if the code changes afterward, but
> >> the includes don't, the PCH file can be reused.
> >>
> >> That works fine when I work on my own. But if another user on another
> >> machine generates the PCH file, the application crashes, both for me
> >> and for the other user, as soon as the compiled function is invoked. I
> >> haven't been able to determine yet what difference in the other user's
> >> environment might cause the problem.
> >>
> >> Does anybody on this list have any idea why a PCH file generated by
> >> another user with exactly the same command line might cause a crash?
> >>
> >> I don't know if it's relevant, but the application is compiled with
> >> clang/llvm 7.0.0. It uses a GeneratePCHAction to generate the PCH
> >> file, and it uses a VerifyPCHAction if the PCH file already exists.
> >> The VerifyPCHAction succeeds, in this case, but the compiled function
> >> still crashes.
> >
> >
> > VerifyPCHAction specifies AllowConfigurationMismatch = true, so it doesn't provide a full check that the PCH is actually usable. Do you also set AllowConfigurationMismatch or DisablieValidation to true when creating the ASTReader to load the PCH file? (How are you loading it? If via code, what are you calling and what arguments are you passing, and if via the clang driver, what flags are you using?)



More information about the cfe-dev mailing list