Bug 193347 - clang++ 3.4.1 segfault
Summary: clang++ 3.4.1 segfault
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-05 13:57 UTC by Ed Maste
Modified: 2014-09-30 15:11 UTC (History)
0 users

See Also:


Attachments
run script (842 bytes, application/x-shellscript)
2014-09-05 14:02 UTC, Ed Maste
no flags Details
preprocessed source (237.13 KB, application/x-xz)
2014-09-05 14:04 UTC, Ed Maste
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2014-09-05 13:57:54 UTC
Preprocessed source and run script in https://github.com/emaste/clangstuff
(will attach in a moment)

[3/1183] Building CXX object lib/Objec...es/LLVMObject.dir/MachOUniversal.cpp.o
FAILED: /usr/bin/clang++   -DLLVMObject_EXPORTS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DGTEST_HAS_RTTI=0 -std=c++11 -stdlib=libc++ -fno-limit-debug-info -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -fcolor-diagnostics -fdata-sections -g -fPIC -Ilib/Object -I../lib/Object -Iinclude -I../include -I/usr/local/include    -fno-exceptions -fno-rtti -MMD -MT lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o -MF "lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o.d" -o lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o -c ../lib/Object/MachOUniversal.cpp
Stack dump:
0.      Program arguments: /usr/bin/clang++ -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name MachOUniversal.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -gdwarf-2 -fdata-sections -coverage-file /tank/emaste/ctsrd/llvm/Build/lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o -resource-dir /usr/bin/../lib/clang/3.4.1 -dependency-file lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o.d -MT lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o -D LLVMObject_EXPORTS -D _DEBUG -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D GTEST_HAS_RTTI=0 -I lib/Object -I ../lib/Object -I include -I ../include -I /usr/local/include -internal-isystem /usr/include/c++/v1 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tank/emaste/ctsrd/llvm/Build -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fstandalone-debug -mstackrealign -fno-rtti -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o -x c++ ../lib/Object/MachOUniversal.cpp 
1.      ../lib/Object/MachOUniversal.cpp:98:1: current parser token 'void'
2.      ../lib/Object/MachOUniversal.cpp:82:54: LLVM IR generation of declaration 'llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive'
3.      ../lib/Object/MachOUniversal.cpp:82:54: Generating code for declaration 'llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive'
4.      ../lib/Object/MachOUniversal.cpp:84:15: LLVM IR generation of compound statement ('{}')
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.0
Thread model: posix
clang++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/MachOUniversal-aa92c5.cpp
clang++: note: diagnostic msg: /tmp/MachOUniversal-aa92c5.sh
clang++: note: diagnostic msg:
Comment 1 Ed Maste freebsd_committer 2014-09-05 14:02:51 UTC
Created attachment 146867 [details]
run script
Comment 2 Ed Maste freebsd_committer 2014-09-05 14:04:49 UTC
Created attachment 146868 [details]
preprocessed source
Comment 3 Ed Maste freebsd_committer 2014-09-05 17:41:51 UTC
I've confirmed that this does not happen with upstream clang++ 3.4.2.
Comment 4 Ed Maste freebsd_committer 2014-09-05 21:21:38 UTC
Additional notes:

* This is only reproducible with -fstandalone-debug

* I cannot reproduce it with any of:
 - clang 3.4.1
 - clang 3.4.2
 - clang 3.4.1 with all of the patches in contrib/llvm/patches/ applied
Comment 5 Ed Maste freebsd_committer 2014-09-08 17:23:14 UTC
freefall, 11.0-CURRENT r269136

SHA256 (/usr/bin/clang++) = f320b63dabc89d5c0b32e293ff4254dc86054be729362eb0a89a08ca5f7001b7

[emaste@freefall ~/clangstuff]$ sh MachOUniversal-a57cc4.sh 
Assertion failed: (D->isCompleteDefinition() && "Cannot layout type before complete!"), function getASTRecordLayout, file /usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp, line 2719.
...
Comment 6 commit-hook freebsd_committer 2014-09-08 18:44:31 UTC
A commit references this bug:

Author: emaste
Date: Mon Sep  8 18:43:33 UTC 2014
New revision: 271282
URL: http://svnweb.freebsd.org/changeset/base/271282

Log:
  Merge Clang debug info crash fix rev 200797:

      Debug info: fix a crasher when when emitting debug info for
      not-yet-completed templated types. getTypeSize() needs a complete type.

      rdar://problem/15931354

  PR:		193347
  MFC after:	3 days
  Sponsored by:	DARPA, AFRL

Changes:
  head/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
Comment 7 commit-hook freebsd_committer 2014-09-08 18:49:32 UTC
A commit references this bug:

Author: emaste
Date: Mon Sep  8 18:48:54 UTC 2014
New revision: 271283
URL: http://svnweb.freebsd.org/changeset/base/271283

Log:
  Add clang patch for r271282

  Note that r271282 contains only the src change from Clang rev 200797.
  This patch file includes two follow-on changes to the test case, which
  do not apply to the copy in the FreeBSD tree.

  Upstream Clang revisions:

  200797:

      Debug info: fix a crasher when when emitting debug info for
      not-yet-completed templated types. getTypeSize() needs a complete type.

      rdar://problem/15931354

  200798:

      Simplify testcase from r200797 some more.

  200805:

      Further simplify r200797 and add an explanatory comment.

  PR:		193347
  MFC after:	3 days
  Sponsored by:	DARPA, AFRL

Changes:
  head/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff
Comment 8 commit-hook freebsd_committer 2014-09-11 01:54:11 UTC
A commit references this bug:

Author: emaste
Date: Thu Sep 11 01:53:56 UTC 2014
New revision: 271414
URL: http://svnweb.freebsd.org/changeset/ports/271414

Log:
  MFC Clang debug info crash fix

  r271282: Merge Clang debug info crash fix rev 200797:

        Debug info: fix a crasher when when emitting debug info for
        not-yet-completed templated types. getTypeSize() needs a complete type.

        rdar://problem/15931354

  r271283: Add clang patch for r271282

    Note that r271282 contains only the src change from Clang rev 200797.
    This patch file includes two follow-on changes to the test case, which
    do not apply to the copy in the FreeBSD tree.

    Upstream Clang revisions:

    200797:

        Debug info: fix a crasher when when emitting debug info for
        not-yet-completed templated types. getTypeSize() needs a complete type.

        rdar://problem/15931354

    200798:

        Simplify testcase from r200797 some more.

    200805:

        Further simplify r200797 and add an explanatory comment.

  PR:		193347
  Approved by:	re
  Sponsored by:	DARPA, AFRL

Changes:
_U  stable/10/
  stable/10/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff
  stable/10/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
Comment 9 commit-hook freebsd_committer 2014-09-30 15:10:48 UTC
A commit references this bug:

Author: emaste
Date: Tue Sep 30 15:10:41 UTC 2014
New revision: 272304
URL: https://svnweb.freebsd.org/changeset/base/272304

Log:
  MFC Clang debug info crash fix

  271282: Merge Clang debug info crash fix rev 200797:

      Debug info: fix a crasher when when emitting debug info for
      not-yet-completed templated types. getTypeSize() needs a complete type.

      rdar://problem/15931354

  271283: Add clang patch for r271282

    Note that r271282 contains only the src change from Clang rev 200797.
    This patch file includes two follow-on changes to the test case, which
    do not apply to the copy in the FreeBSD tree.

    Upstream Clang revisions:

    200797:

      Debug info: fix a crasher when when emitting debug info for
      not-yet-completed templated types. getTypeSize() needs a complete type.

      rdar://problem/15931354

    200798:

      Simplify testcase from r200797 some more.

    200805:

      Further simplify r200797 and add an explanatory comment.

  PR:		193347

Changes:
_U  stable/9/contrib/llvm/
  stable/9/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff
_U  stable/9/contrib/llvm/tools/clang/
  stable/9/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp