[llvm-dev] ICE in release/9.x when using LLVM_ENABLE_MODULES

Brian Gesiak via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 29 06:40:38 PDT 2019


I ran into an LLVM/Clang crash when attempting to do the following:

1. Build Clang from the release/9.x branch source.
2. Use the Clang from (1) to build clangd on the release/9.x branch,
with LLVM_ENABLE_MODULES=On.

I wrote a script to reproduce the crash:
https://gist.github.com/modocache/ac366ca9673b93bb21e75d3e72162608

At the above URL, you'll find a script `repro.sh` that reproduces the
crash, and a file `out.txt` that contains the build output and the
stack trace.

I used the script to bisect, and bisect determined the first "bad" commit was:
https://github.com/llvm/llvm-project/commit/baae41ff76f662987f31447686ba819dcd748b3f

The stack trace appears to crash when generating code for an
`llvm::Expected` declaration, and the commit above seems to add a few
of them, so that seems suspicious. The stack trace is in the GitHub
gist URL above, but I'll also paste the relevant portion here:

```
Stack dump:
0. Program arguments: ...
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. /home/modocache/Source/llvm/git/dev/llvm-project/llvm/include/llvm/Support/Error.h:625:17:
Generating code for declaration
'llvm::Expected<std::__cxx11::basic_string<char> >::getStorage'
/home/modocache/Source/llvm/git/dev/build-s1/bin/clang-9(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x557bc131549a]
/home/modocache/Source/llvm/git/dev/build-s1/bin/clang-9(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x557bc13131b4]
/home/modocache/Source/llvm/git/dev/build-s1/bin/clang-9(+0x1649335)[0x557bc1313335]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13f40)[0x7f3bc780af40]
/home/modocache/Source/llvm/git/dev/build-s1/bin/clang-9(_ZN5clang7CodeGen15CodeGenFunction18EmitLValueForFieldENS0_6LValueEPKNS_9FieldDeclE+0x8ad)[0x557bc1749abd]
```

I have an immediate workaround -- I can turn off LLVM_ENABLE_MODULES,
and the crash goes away. However, I think it might be worth looking
into the commit above and determining why it crashes when using
`-fmodules`. At first glance, I don't see the problem, but I've cc'ed
the author, in case they might know more.

Does anyone have any ideas on how to fix the underlying crash?

- Brian Gesiak


More information about the llvm-dev mailing list