Bug 200362 - clang crash in buildkernel
Summary: clang crash in buildkernel
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
Depends on:
Reported: 2015-05-21 08:38 UTC by Andriy Gapon
Modified: 2016-10-12 11:55 UTC (History)
1 user (show)

See Also:

compressed source file (237.98 KB, application/x-bzip)
2015-05-21 08:39 UTC, Andriy Gapon
no flags Details
script (1.26 KB, application/x-shellscript)
2015-05-21 08:39 UTC, Andriy Gapon
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Gapon freebsd_committer 2015-05-21 08:38:09 UTC
Assertion failed: (!isCommon()), function getOffset, file /usr/src/lib/clang/libllvmmc/../../../contrib/llvm/include/llvm/MC/MCAssembler.h, line 736.
Stack dump:
0.      Program arguments: /usr/obj/usr/src/tmp/usr/bin/cc -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -disable-free -main-file-name sched_ule.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -mdisable-tail-calls -masm-verbose -mconstructor-aliases -mcode-model kernel -target-cpu amdfam10 -target-feature -mmx -target-feature -sse -target-feature -aes -target-feature -avx -disable-red-zone -no-implicit-float -gdwarf-2 -dwarf-column-info -coverage-file /usr/obj/usr/src/sys/TRANT/sched_ule.c -nostdsysteminc -nobuiltininc -resource-dir /usr/obj/usr/src/tmp/usr/bin/../lib/clang/3.6.0 -include opt_global.h -D _KERNEL -D HAVE_KERNEL_OPTION_HEADERS -D __printf__=__freebsd_kprintf__ -I . -I /usr/src/sys -I /usr/src/sys/contrib/libfdt -isysroot /usr/obj/usr/src/tmp -O2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Werror -std=iso9899:1999 -fdebug-compilation-dir /usr/obj/usr/src/sys/TRANT -ferror-limit 19 -fmessage-length 230 -ffreestanding -fwrapv -stack-protector 1 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o sched_ule.o -x c /usr/src/sys/kern/sched_ule.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/usr/src/sys/kern/sched_ule.c'.
4.      Running pass 'X86 Assembly / Object Emitter' on function '@sched_switch'
cc: error: unable to execute command: Abort trap (core dumped)
cc: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 3.6.0 (tags/RELEASE_360/final 230434) 20150225
Target: x86_64-unknown-freebsd11.0
Thread model: posix
cc: 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.
cc: note: diagnostic msg:

Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/sched_ule-ec2890.c
cc: note: diagnostic msg: /tmp/sched_ule-ec2890.sh
cc: note: diagnostic msg:

*** Error code 254
Comment 1 Andriy Gapon freebsd_committer 2015-05-21 08:39:07 UTC
Created attachment 156996 [details]
compressed source file
Comment 2 Andriy Gapon freebsd_committer 2015-05-21 08:39:43 UTC
Created attachment 156997 [details]
Comment 3 Andriy Gapon freebsd_committer 2015-05-21 09:05:58 UTC
I must also note that the problem happens with a locally modified source tree.
In particular there is some "hardcore" stuff in SDT_PROBE_FUNC_(), SDT_CALL_START(), STD_CALL_END_().
Comment 4 Dimitry Andric freebsd_committer 2015-05-21 18:11:14 UTC
Reproduced and filed upstream here: http://llvm.org/PR23621

The problem is that several .comm symbols get defined multiple times, with the same name.  Apparently the clang MC assembler has an assertion for this.

As a workaround, you can either try to ensure the .comm symbols all have unique names, or use the -no-integrated-as flag, to use the GNU assembler, which apparently just ignores the duplicated .comm symbols.
Comment 5 Andriy Gapon freebsd_committer 2015-05-21 20:37:25 UTC
(In reply to Dimitry Andric from comment #4)
Thank you very much for the research, the upstream report and the suggestions!
I'm using a workaround now.
Comment 6 Andriy Gapon freebsd_committer 2016-10-12 11:55:15 UTC
Seems like that this was fixed in clang more than a year ago and the fix is already in FreeBSD.