Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm-cbe crashes at .ll ouput from clang++-10 (plzip-1.9 lzip_index.c) #133

Open
makise-homura opened this issue May 27, 2021 · 2 comments

Comments

@makise-homura
Copy link
Contributor

Say, we have LLVM 10.0.0, and just have built llvm-cbe in current directory.

Trying to build lzip_index.cc from plzip-1.9 with lzlib-1.12:

wget -q http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.12.tar.gz
wget -q http://download.savannah.gnu.org/releases/lzip/plzip/plzip-1.9.tar.gz
tar xf plzip-1.9.tar.gz
tar xf lzlib-1.12.tar.gz
clang++-10 -S -emit-llvm -g -Iplzip-1.9 -Ilzlib-1.12 -o lzip_index.ll plzip-1.9/lzip_index.cc
./llvm-cbe lzip_index.ll

And it crashes with SIGSEGV with the following stack trace:

#0 0x00007f369d0a44ff llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm-10/lib/libLLVM-10.so.1+0x9814ff)
#1 0x00007f369d0a2782 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-10/lib/libLLVM-10.so.1+0x97f782)
#2 0x00007f369d0a4ac5 (/usr/lib/llvm-10/lib/libLLVM-10.so.1+0x981ac5)
#3 0x00007f369c34a210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
#4 0x00007f369d1355fc llvm::DataLayout::getAlignmentInfo(llvm::AlignTypeEnum, unsigned int, bool, llvm::Type*) const (/usr/lib/llvm-10/lib/libLLVM-10.so.1+0xa125fc)
#5 0x00005558f07d71b0
Stack dump:
0.      Program arguments: ./llvm-cbe lzip_index.ll

The same is on LLVM 11.0.0 and 9.0.0 (but no stack trace somehow). Interestingly, on LLVM 8.0.0, there is no failure, .cbe.c output is being produced correctly, but issue #132 occurs then.

@makise-homura
Copy link
Contributor Author

Simple reproduction example (lzip_index.cc):

class Lzip_index
{
  const long long insize;
public:
  Lzip_index();
};
Lzip_index::Lzip_index() : insize(0) {;}

Build: clang++-10 -S -emit-llvm -g -o lzip_index.ll lzip_index.cc && ./llvm-cbe lzip_index.ll

@YenForYang
Copy link

I seem to be getting a similar error with archive.cpp from UnRAR source (https://www.rarlab.com/rar/unrarsrc-6.0.6.tar.gz).

/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x7f35a5700c8f]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x22)[0x7f35a56fef22]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(+0xb21255)[0x7f35a5701255]
/lib/x86_64-linux-gnu/libc.so.6(+0x3bd60)[0x7f35a470bd60]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZNK4llvm10DataLayout16getAlignmentInfoENS_13AlignTypeEnumEjbPNS_4TypeE+0x4c)[0x7f35a579289c]
[0xe94600]
Stack dump:
0.      Program arguments: ./llvm-cbe --cbe-declare-locals-late archive.ll
[1]    23956 segmentation fault (core dumped)  ./llvm-cbe --cbe-declare-locals-late

I ran llvm-cbe archive.ll through valgrind's memcheck as well,

 Invalid read of size 4
    at 0x541389C: operator() (llvm/lib/IR/DataLayout.cpp:481)
    by 0x541389C: partition_point<llvm::LayoutAlignElem *, (lambda at /build/llvm-toolchain-10-10.0.1~++20210313014605+ef32c611aa21/llvm/lib/IR/DataLayout.cpp:480:38)> (stl_algo.h:626)
    by 0x541389C: partition_point<llvm::SmallVector<llvm::LayoutAlignElem, 16> &, (lambda at /build/llvm-toolchain-10-10.0.1~++20210313014605+ef32c611aa21/llvm/lib/IR/DataLayout.cpp:480:38), llvm::LayoutAlignElem &> (llvm/include/llvm/ADT/STLExtras.h:1320)
    by 0x541389C: findAlignmentLowerBound (llvm/lib/IR/DataLayout.cpp:480)
    by 0x541389C: findAlignmentLowerBound (llvm/include/llvm/IR/DataLayout.h:149)
    by 0x541389C: llvm::DataLayout::getAlignmentInfo(llvm::AlignTypeEnum, unsigned int, bool, llvm::Type*) const (llvm/lib/IR/DataLayout.cpp:542)
    by 0x9A9B59F: ???
    by 0x44ABF7: llvm_cbe::CWriter::doFinalization(llvm::Module&) (lib/Target/CBackend/CBackend.cpp:2322)
    by 0x5488100: llvm::FPPassManager::doFinalization(llvm::Module&) (llvm/lib/IR/LegacyPassManager.cpp:1535)
    by 0x54885C1: runOnModule (llvm/lib/IR/LegacyPassManager.cpp:1611)
    by 0x54885C1: llvm::legacy::PassManagerImpl::run(llvm::Module&) (llvm/lib/IR/LegacyPassManager.cpp:1694)
    by 0x416744: compileModule(char**, llvm::LLVMContext&) (tools/llvm-cbe/llvm-cbe.cpp:427)
    by 0x415524: main (tools/llvm-cbe/llvm-cbe.cpp:242)
  Address 0xfdc8e647f4ed9308 is not stack'd, malloc'd or (recently) free'd

 Process terminating with default action of signal 11 (SIGSEGV)
  General Protection Fault
    at 0x541389C: operator() (llvm/lib/IR/DataLayout.cpp:481)
    by 0x541389C: partition_point<llvm::LayoutAlignElem *, (lambda at /build/llvm-toolchain-10-10.0.1~++20210313014605+ef32c611aa21/llvm/lib/IR/DataLayout.cpp:480:38)> (stl_algo.h:626)
    by 0x541389C: partition_point<llvm::SmallVector<llvm::LayoutAlignElem, 16> &, (lambda at /build/llvm-toolchain-10-10.0.1~++20210313014605+ef32c611aa21/llvm/lib/IR/DataLayout.cpp:480:38), llvm::LayoutAlignElem &> (llvm/include/llvm/ADT/STLExtras.h:1320)
    by 0x541389C: findAlignmentLowerBound (llvm/lib/IR/DataLayout.cpp:480)
    by 0x541389C: findAlignmentLowerBound (llvm/include/llvm/IR/DataLayout.h:149)
    by 0x541389C: llvm::DataLayout::getAlignmentInfo(llvm::AlignTypeEnum, unsigned int, bool, llvm::Type*) const (llvm/lib/IR/DataLayout.cpp:542)
    by 0x9A9B59F: ???
    by 0x44ABF7: llvm_cbe::CWriter::doFinalization(llvm::Module&) (lib/Target/CBackend/CBackend.cpp:2322)
    by 0x5488100: llvm::FPPassManager::doFinalization(llvm::Module&) (llvm/lib/IR/LegacyPassManager.cpp:1535)
    by 0x54885C1: runOnModule (llvm/lib/IR/LegacyPassManager.cpp:1611)
    by 0x54885C1: llvm::legacy::PassManagerImpl::run(llvm::Module&) (llvm/lib/IR/LegacyPassManager.cpp:1694)
    by 0x416744: compileModule(char**, llvm::LLVMContext&) (tools/llvm-cbe/llvm-cbe.cpp:427)
    by 0x415524: main (tools/llvm-cbe/llvm-cbe.cpp:242)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants