https://sourceware.org/bugzilla/show_bug.cgi?id=29006
Bug ID: 29006
Summary: alloc(): invalid size (unsorted) with
-fstack-protector -lssp
Product: binutils
Version: 2.38
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: manisandro at gmail dot com
Target Milestone: ---
I'm trying to build mingw-llvm-1.14.0 [1] with
mingw-binutils-2.38-1.fc37.x86_64, mingw-gcc-12.0.1-1.fc37.x86_64.
[1] https://smani.fedorapeople.org/mingw-llvm-14.0.0-1.fc37.src.rpm
Linking llvm-cvtres.exe fails with
malloc(): invalid size (unsorted)
collect2: fatal error: ld terminated with signal 6 [Aborted], core dumped
compilation terminated.
Reduced command line:
$ i686-w64-mingw32-g++ -fstack-protector -lssp -Wl,--whole-archive
CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive -o
../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
Note: Error only appears if both -fstack-protector and -lssp are present.
Appears to be a regression since mingw-binutils-2.37-5.fc37.
Valgrind says:
$ valgrind i686-w64-mingw32-g++ -fstack-protector -lssp -Wl,--whole-archive
CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive -o
../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
==794194== Memcheck, a memory error detector
==794194== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==794194== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==794194== Command: i686-w64-mingw32-g++ -fstack-protector -lssp
-Wl,--whole-archive CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive
-o ../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
==794194==
malloc(): invalid size (unsorted)
collect2: fatal error: ld terminated with signal 6 [Aborted], core dumped
compilation terminated.
[sandro@PC4 llvm-cvtres]$ valgrind --trace-children=yes i686-w64-mingw32-g++
-fstack-protector -lssp -Wl,--whole-archive
CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive -o
../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
==794496== Memcheck, a memory error detector
==794496== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==794496== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==794496== Command: i686-w64-mingw32-g++ -fstack-protector -lssp
-Wl,--whole-archive CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive
-o ../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
==794496==
==794496== Memcheck, a memory error detector
==794496== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==794496== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==794496== Command: /usr/bin/i686-w64-mingw32-g++ -fstack-protector -lssp
-Wl,--whole-archive CMakeFiles/llvm-cvtres.dir/objects.a -Wl,--no-whole-archive
-o ../../bin/llvm-cvtres.exe @CMakeFiles/llvm-cvtres.dir/linklibs.rsp
==794496==
==794497== Memcheck, a memory error detector
==794497== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==794497== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==794497== Command: /usr/libexec/gcc/i686-w64-mingw32/12.0.1/collect2 -plugin
/usr/libexec/gcc/i686-w64-mingw32/12.0.1/liblto_plugin.so
-plugin-opt=/usr/libexec/gcc/i686-w64-mingw32/12.0.1/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccimcNFc.res -plugin-opt=-pass-through=-lmingw32
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex
-plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32
-plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32
-plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32
-plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex
-plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32
--sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic -u
___register_frame_info -u ___deregister_frame_info -o ../../bin/llvm-cvtres.exe
/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o
/usr/lib/gcc/i686-w64-mingw32/12.0.1/crtbegin.o
-L/usr/lib/gcc/i686-w64-mingw32/12.0.1
-L/usr/lib/gcc/i686-w64-mingw32/12.0.1/../../../../i686-w64-mingw32/lib/../lib
-L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib
-L/usr/lib/gcc/i686-w64-mingw32/12.0.1/../../../../i686-w64-mingw32/lib
-L/usr/i686-w64-mingw32/sys-root/mingw/lib @/tmp/ccqLXUyr -lssp_nonshared -lssp
-lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread
-ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname
-lmingwex -lmsvcrt -lkernel32 /usr/lib/gcc/i686-w64-mingw32