ld crash generating map file for c++11 auto return type inference
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
binutils (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
New
|
Undecided
|
Unassigned |
Bug Description
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=
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_
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-
Candidate: 2.26.1-
Version table:
*** 2.26.1-
500 http://
100 /var/lib/
2.26-8ubuntu2 500
500 http://
gcc:
Installed: 4:5.3.1-1ubuntu1
Candidate: 4:5.3.1-1ubuntu1
Version table:
*** 4:5.3.1-1ubuntu1 500
500 http://
100 /var/lib/
g++:
Installed: 4:5.3.1-1ubuntu1
Candidate: 4:5.3.1-1ubuntu1
Version table:
*** 4:5.3.1-1ubuntu1 500
500 http://
100 /var/lib/
Does not reproduce on 14.04, with binutils- 2.24-5ubuntu14. 1, g++/gcc- 4:4.8.2- 1ubuntu6