[cfe-dev] Clang 'locks up' when compiling optimized

David Barto via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 27 06:45:39 PDT 2017


The file isn’t very large, at 181949 bytes, and is a machine generated bit of code.

The strange thing is that if I run the compile by hand by cutting/pasting the line into a shell window, it compiles in seconds. I run the same code generation/compile/execution with g++ (5.1) and it never locks up.

Another thing, the code is compiled from a daemon that places the compiler under execution limits. If it runs for more than 30 seconds or uses more than 500MB of RAM, it should have the appropriate limit applied to it. I fork the daemon and before exec() for the compiler do the following:

      struct rlimit rlim;
      rlim.rlim_cur = rlim.rlim_max = m_compile_max_seconds;	// 30

      if (0 != setrlimit(RLIMIT_CPU, &rlim))
      {
        xthrow(Sys_rlimit, errno, "system", "can't bound compilation time");
      }

      rlim.rlim_cur = rlim.rlim_max = m_compile_max_memory * (1 << 20);	// 500 MB

      if (0 != setrlimit(RLIMIT_AS, &rlim))
      {
        xthrow(Sys_rlimit, errno, "system", "can't limit compiler memory usage");
      }

This is the compile that locked up. If anyone believes that looking at the source would make a difference, let me know and I’ll send it along.

  501 59880 46191     4004   0  31 10  2495004   9612 -      SN                  0 ??         0:00.02 /opt/local/libexec/llvm-4.0/bin/clang++ -pipe -c -o /Users/barto/UnixEnvironment/CSI/internal/repo4/internal.0/code/381/1.opt -O3 -Winvalid-pch -march=core2 -fstack-protector-strong -D_BSD_SOURCE -DFOR_SPARQL -D_REENTRANT -D_PTHREADS -DTHREAD -D_GLIBCXX_USE_DEPRECATED=0 -DTURBO_GENCODE=1 -DDO_CASSANDRA=0 -DMEM_LIMIT_LEAK_CHECKING -DFULL_RESERVATIONS -DGCC5 -D_DARWIN_C_SOURCE -DDARWIN -DMAC_OSX=1 -std=gnu++14 -m64 -fPIC -I/Users/barto/UnixEnvironment/CSI/repo4/lib -I/Users/barto/UnixEnvironment/CSI/repo4/lib/cgrsrc /Users/barto/UnixEnvironment/CSI/internal/repo4/internal.0/code/381/1.cpp
  501 59881 59880     4004   0  31 10  2554904  33884 -      SN                  0 ??        21:37.14 /opt/local/libexec/llvm-4.0/bin/clang -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name 1.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -dwarf-column-info -debugger-tuning=lldb -coverage-notes-file /Users/barto/UnixEnvironment/CSI/internal/repo4/internal.0/code/381/1.gcno -resource-dir /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0 -D _BSD_SOURCE -D FOR_SPARQL -D _REENTRANT -D _PTHREADS -D THREAD -D _GLIBCXX_USE_DEPRECATED=0 -D TURBO_GENCODE=1 -D DO_CASSANDRA=0 -D MEM_LIMIT_LEAK_CHECKING -D FULL_RESERVATIONS -D GCC5 -D _DARWIN_C_SOURCE -D DARWIN -D MAC_OSX=1 -I /Users/barto/UnixEnvironment/CSI/repo4/lib -I /Users/barto/UnixEnvironment/CSI/repo4/lib/cgrsrc -stdlib=libc++ -O3 -Winvalid-pch -std=gnu++14 -fdeprecated-macro -fdebug-compilation-dir /Users/barto/UnixEnvironment/CSI/repo4/bin -ferror-limit 19 -fmessage-length 0 -stack-protector 2 -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /Users/barto/UnixEnvironment/CSI/internal/repo4/internal.0/code/381/1.opt -x c++ /Users/barto/UnixEnvironment/CSI/internal/repo4/internal.0/code/381/1.cpp

	David


David Barto
barto at cambridgesemantics.com

Sometimes, my best code does nothing. Most of the rest of it has bugs.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170627/36ee97b2/attachment.html>


More information about the cfe-dev mailing list