[llvm-dev] Crash with llvm 8.0.0 and -fembed-bitcode option

Garba Peter via llvm-dev llvm-dev at lists.llvm.org
Thu May 23 08:26:51 PDT 2019


I found a bug in llvm 8.0.0.
When you compile with the "-fembed-bitcode" option it will lead to a crash when executing the output binary.

For unknown reason the assembled x86 code is different when the "-fembed-bitcode" option is supplied.

It works with clang 7.0.1

#include <string>
#include <iostream>

int func(int a);

int main(int argc, char **argv) {
std::string s = std::to_string(func(argc));
std::cout << s << std::endl;
return 0;

int func(int a) {
return a+1;

Compile with:

=> clang++-8 a.cpp b.cpp -fembed-bitcode && ./a.out

and it fails:

=> [1]    14811 segmentation fault (core dumped)  ./a.out

Compile with:

=> clang++-8 a.cpp b.cpp  && ./a.out

and it works:

=> 2

Best Regards,




Peter Garba
Software Security Expert

Gemalto is now part of the Thales Group.
Please note that my new email address is peter.garba at thalesgroup.com<mailto:peter.garba at thalesgroup.com>


Werinherstr. 81

81541 Munich


This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190523/c674f98b/attachment.html>

More information about the llvm-dev mailing list