[llvm-bugs] [Bug 26423] New: Segfaulting on C++ ADL

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 1 12:50:04 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26423

            Bug ID: 26423
           Summary: Segfaulting on C++ ADL
           Product: clang
           Version: 3.7
          Hardware: Macintosh
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lotham2003 at yahoo.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I was trying to get my code to get along with ADL. clang seemed a little
confused, suggesting that I put the file it couldn't find into REDACTED::util,
when the parameter in question is in REDACTED::test::mock and the function
using ADL was in REDACTED::sidx::cnc. Following its advice and putting the
function in REDACTED::util caused this segfault. My workaround was to put the
function in REDACTED::sidx::cnc and then reorder the includes to be sure that
the function declaration was always included before its ADL reference in
CacheUpdateJob.h

Here is the error that Clang gave me:



#0 0x159672d llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/clang-3.7+0x159672d)
#1 0x1595621 SignalHandler(int) (/usr/local/bin/clang-3.7+0x1595621)
#2 0x7f584bd7c790 __restore_rt (/lib64/libpthread.so.0+0xf790)
#3 0x1756d72 UnwrapTypeForDebugInfo(clang::QualType, clang::ASTContext const&)
[clone .constprop.764] (/usr/local/bin/clang-3.7+0x1756d72)
#4 0x175df19 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType,
llvm::DIFile*) (/usr/local/bin/clang-3.7+0x175df19)
#5 0x175f1c2 clang::CodeGen::CGDebugInfo::CreateType(clang::FunctionType
const*, llvm::DIFile*) (/usr/local/bin/clang-3.7+0x175f1c2)
#6 0x175df46 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType,
llvm::DIFile*) (/usr/local/bin/clang-3.7+0x175df46)
#7 0x17647bb clang::CodeGen::CGDebugInfo::getOrCreateFunctionType(clang::Decl
const*, clang::QualType, llvm::DIFile*) (/usr/local/bin/clang-3.7+0x17647bb)
#8 0x1764dbd
clang::CodeGen::CGDebugInfo::getFunctionForwardDeclaration(clang::FunctionDecl
const*) (/usr/local/bin/clang-3.7+0x1764dbd)
#9 0x17653c0
clang::CodeGen::CGDebugInfo::getDeclarationOrDefinition(clang::Decl const*)
(/usr/local/bin/clang-3.7+0x17653c0)
#10 0x17654ba clang::CodeGen::CGDebugInfo::EmitUsingDecl(clang::UsingDecl
const&) (/usr/local/bin/clang-3.7+0x17654ba)
#11 0x181cf97 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt
const&) (/usr/local/bin/clang-3.7+0x181cf97)
#12 0x1826627 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt
const*) (/usr/local/bin/clang-3.7+0x1826627)
#13 0x1822980 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*)
(/usr/local/bin/clang-3.7+0x1822980)
#14 0x1822dcf
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/local/bin/clang-3.7+0x1822dcf)
#15 0x18410a2
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) (/usr/local/bin/clang-3.7+0x18410a2)
#16 0x18475a3 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/local/bin/clang-3.7+0x18475a3)
#17 0x16ab781
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/bin/clang-3.7+0x16ab781)
#18 0x16b84c5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/bin/clang-3.7+0x16b84c5)
#19 0x16b861e clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/local/bin/clang-3.7+0x16b861e)
#20 0x16b863a clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/local/bin/clang-3.7+0x16b863a)
#21 0x16b863a clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/local/bin/clang-3.7+0x16b863a)
#22 0x16b86f9 clang::CodeGen::CodeGenModule::Release()
(/usr/local/bin/clang-3.7+0x16b86f9)
#23 0x1b7233d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/bin/clang-3.7+0x1b7233d)
#24 0x1e20082 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/bin/clang-3.7+0x1e20082)
#25 0x19198d6 clang::FrontendAction::Execute()
(/usr/local/bin/clang-3.7+0x19198d6)
#26 0x18f20e9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/bin/clang-3.7+0x18f20e9)
#27 0x19925fb clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/bin/clang-3.7+0x19925fb)
#28 0x6e8200 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/bin/clang-3.7+0x6e8200)
#29 0x6e4ce2 main (/usr/local/bin/clang-3.7+0x6e4ce2)
#30 0x7f584afbad5d __libc_start_main (/lib64/libc.so.6+0x1ed5d)
#31 0x6e3819 _start (/usr/local/bin/clang-3.7+0x6e3819)
Stack dump:
0.    Program arguments: /usr/local/bin/clang-3.7 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name UnitTestMySQLJob.cpp -mrelocation-model
static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -g
-dwarf-column-info -coverage-file [path redacted]/UnitTestMySQLJob.o
-resource-dir /usr/local/bin/../lib/clang/3.7.0 -isystem . -isystem
./lib/cpp/boost_1_59_0 -isystem ./lib/cpp/ms_gsl_206 -I . -I ./inc
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/x86_64-unknown-linux-gnu
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/bin/../lib/clang/3.7.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O0 -Wall -Wextra -Weverything
-Wno-c++98-compat -Wno-c++98-compat-pedantic -Werror -pedantic-errors
-std=c++14 -fdeprecated-macro -fdebug-compilation-dir [path redacted]
-ferror-limit 123 -fmessage-length 107 -mstackrealign -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -o
test/UnitTestMySQLJob.o -x c++ test/UnitTestMySQLJob.cpp
1.    <eof> parser at end of file
2.    Per-file LLVM IR generation
3.    ./inc/cnc/CacheUpdateJob.h:104:10: Generating code for declaration
‘NAMESPACE_REDACTED::sidx::cnc::CacheUpdateJob<NAMESPACE_REDACTED::sidx::cnc::JobConfig<NAMESPACE_REDACTED::test::mock::SocketReader,
NAMESPACE_REDACTED::test::mock::UnixSocket,
NAMESPACE_REDACTED::test::mock::MySQLConnectionProvider,
NAMESPACE_REDACTED::test::mock::Result<NAMESPACE_REDACTED::sidx::cnc::CLASSNAME_REDACTED>
> >::SetResult'
clang-3.7: error: unable to execute command: Segmentation fault
clang-3.7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (tags/RELEASE_370/final 253618)
(llvm/tags/RELEASE_370/final 253620)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.7: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.7: note: diagnostic msg: /tmp/UnitTestMySQLJob-1327b2.cpp
clang-3.7: note: diagnostic msg: /tmp/UnitTestMySQLJob-1327b2.sh
clang-3.7: note: diagnostic msg:

********************



The requested .cpp file is attached.

And here is the .sh file that clang requested (see a few lines above):



# Crash reproducer for clang version 3.7.0 (tags/RELEASE_370/final 253618)
(llvm/tags/RELEASE_370/final 253620)
# Driver args: "--driver-mode=g++" "-std=c++14" "-g" "-O0" "-Wall" "-Wextra"
"-Weverything" "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Werror"
"-pedantic-errors" "-ferror-limit=123" "-isystem" "." "-I" "." "-I" "./inc"
"-isystem" "./lib/cpp/boost_1_59_0" "-isystem" "./lib/cpp/ms_gsl_206" "-c"
"test/UnitTestMySQLJob.cpp" "-o" "test/UnitTestMySQLJob.o"
# Original command:  "/usr/local/bin/clang-3.7" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "UnitTestMySQLJob.cpp"
"-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim"
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables"
"-fuse-init-array" "-target-cpu" "x86-64" "-g" "-dwarf-column-info"
"-coverage-file" "[path redacted]/test/UnitTestMySQLJob.o" "-resource-dir"
"/usr/local/bin/../lib/clang/3.7.0" "-isystem" "." "-isystem"
"./lib/cpp/boost_1_59_0" "-isystem" "./lib/cpp/ms_gsl_206" "-I" "." "-I"
"./inc" "-internal-isystem"
"/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0"
"-internal-isystem"
"/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/x86_64-unknown-linux-gnu"
"-internal-isystem"
"/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/backward"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/local/bin/../lib/clang/3.7.0/include" "-internal-externc-isystem"
"/include" "-internal-externc-isystem" "/usr/include" "-O0" "-Wall" "-Wextra"
"-Weverything" "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Werror"
"-pedantic-errors" "-std=c++14" "-fdeprecated-macro" "-fdebug-compilation-dir"
"[path redacted]" "-ferror-limit" "123" "-fmessage-length" "107"
"-mstackrealign" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-o" "test/UnitTestMySQLJob.o" "-x" "c++"
"test/UnitTestMySQLJob.cpp"
"/usr/local/bin/clang-3.7" "-cc1" "-triple" "x86_64-unknown-linux-gnu"
"-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier"
"-main-file-name" "UnitTestMySQLJob.cpp" "-mrelocation-model" "static"
"-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose"
"-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu"
"x86-64" "-g" "-dwarf-column-info" "-O0" "-Wall" "-Wextra" "-Weverything"
"-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Werror" "-pedantic-errors"
"-std=c++14" "-fdeprecated-macro" "-ferror-limit" "123" "-fmessage-length"
"107" "-mstackrealign" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-x" "c++" "UnitTestMySQLJob-1327b2.cpp"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160201/fc53ea1b/attachment-0001.html>


More information about the llvm-bugs mailing list