Public bug reported: I'm getting a crash in ld while linking C++-11 auto return type code. ld starts madly allocating memory until your memory and swap are filled, then seg-faults. Use ulimit to avoid swap thrashing while reproducing:
$ ulimit -v 2147483648 # 2GB $ g++ -Wall -ggdb -O0 --std=c++11 -Werror -Wl,-Map=_timing.map _timing_ld_crash_map.cpp -o _timing collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped compilation terminated. I've reduced the input source which is attached as _timing_ld_crash_map.cpp. The following changes (on their own) make the problem "go away": 1. remove -Wl,-Map=...map from the command-line 2. stepping up to -O1 or higher. -Og fails must like -O0. 3. Making `runTest` `static` It seems likely the compiler is emitting a symbol or symbols causing binutils to choke during mapfile generation. Its possible the compiler could be partly at fault, but clearly ld shouldn't max out the memory. Wrapping the body (not the #includes) in #pragma optimisation for -O3 doesn't fix things so likely the std library symbols in <vector> are part of the problem. $ lsb_release -rd Description: Ubuntu 16.04 LTS Release: 16.04 $ apt-cache policy binutils gcc g++ binutils: Installed: 2.26.1-1ubuntu1~16.04.1 Candidate: 2.26.1-1ubuntu1~16.04.1 Version table: *** 2.26.1-1ubuntu1~16.04.1 500 500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages 100 /var/lib/dpkg/status 2.26-8ubuntu2 500 500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages gcc: Installed: 4:5.3.1-1ubuntu1 Candidate: 4:5.3.1-1ubuntu1 Version table: *** 4:5.3.1-1ubuntu1 500 500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages 100 /var/lib/dpkg/status g++: Installed: 4:5.3.1-1ubuntu1 Candidate: 4:5.3.1-1ubuntu1 Version table: *** 4:5.3.1-1ubuntu1 500 500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages 100 /var/lib/dpkg/status ** Affects: binutils (Ubuntu) Importance: Undecided Status: New ** Attachment added: "Source file to reproduce the crash" https://bugs.launchpad.net/bugs/1608898/+attachment/4712322/+files/_timing_ld_crash_map.cpp -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1608898 Title: ld crash generating map file for c++11 auto return type inference To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/1608898/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs