[llvm-bugs] [Bug 50101] New: lld/mac sometimes use-after-frees in parallel linkedit writing

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 23 07:25:47 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50101

            Bug ID: 50101
           Summary: lld/mac sometimes use-after-frees in parallel linkedit
                    writing
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: MachO
          Assignee: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: gkm at fb.com, jezreel at gmail.com,
                    llvm-bugs at lists.llvm.org, smeenai at fb.com

I got this during a full chromium build (with today's trunk lld):

[23601/35445] LINK ./run_testserver
FAILED: run_testserver 
TOOL_VERSION=1615494527 ../../build/toolchain/apple/linker_driver.py
-Wcrl,strippath,../../build/mac_files/xcode_binaries/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip
../../third_party/llvm-build/Release+Asserts/bin/clang++  -fuse-ld=lld
-Wl,--color-diagnostics -stdlib=libc++ --target=x86_64-apple-macos -Werror
-Wl,-dead_strip -nostdlib++ -isysroot
../../build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
-mmacosx-version-min=10.11.0 -Wl,-ObjC -o "./run_testserver"
-Wl,-filelist,"./run_testserver.rsp" -framework Security -framework
ApplicationServices -framework AppKit -framework CoreFoundation -framework
IOKit -framework OpenDirectory -framework Foundation -framework CFNetwork
-framework CoreServices -framework SystemConfiguration   -lbsm -lpmenergy
-lpmsample -lresolv
ld64.lld: warning: Option `-dead_strip' is not yet implemented. Stay tuned...
free(): invalid next size (fast)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments:
/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld
-demangle -dynamic -arch x86_64 -platform_version macos 10.11.0 11.1
-syslibroot
../../build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
-o ./run_testserver --color-diagnostics -dead_strip -ObjC -filelist
./run_testserver.rsp -framework Security -framework ApplicationServices
-framework AppKit -framework CoreFoundation -framework IOKit -framework
OpenDirectory -framework Foundation -framework CFNetwork -framework
CoreServices -framework SystemConfiguration -lbsm -lpmenergy -lpmsample
-lresolv -lSystem
/usr/local/google/home/thakis/src/chrome/src/third_party/llvm-build/Release+Asserts/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
 #0 0x0000000001eca7ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1eca7ec)
 #1 0x0000000001ec86be llvm::sys::RunSignalHandlers()
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1ec86be)
 #2 0x0000000001ecab3f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f6e627ec140 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #4 0x00007f6e62156ce1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f6e62140537 abort ./stdlib/abort.c:81:7
 #6 0x00007f6e62199768 __libc_message
./libio/../sysdeps/posix/libc_fatal.c:156:1
 #7 0x00007f6e621a0a5a ./malloc/malloc.c:5348:3
 #8 0x00007f6e621a1c94 _int_free ./malloc/malloc.c:4249:4
 #9 0x0000000001db7fbb std::_Function_handler<void (), void
llvm::parallel::detail::parallel_for_each_n<unsigned long, (anonymous
namespace)::Writer::writeUuid()::$_2>(unsigned long, unsigned long, (anonymous
namespace)::Writer::writeUuid()::$_2)::'lambda'()>::_M_manager(std::_Any_data&,
std::_Any_data const&, std::_Manager_operation) Writer.cpp:0:0
#10 0x0000000001db2d1d (anonymous namespace)::Writer::writeOutputFile()
Writer.cpp:0:0
#11 0x0000000001db98f2 void lld::macho::writeResult<lld::macho::LP64>()
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1db98f2)
#12 0x0000000001d81d29 lld::macho::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&, llvm::raw_ostream&)
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1d81d29)
#13 0x0000000001ab2e13 lldMain(int, char const**, llvm::raw_ostream&,
llvm::raw_ostream&, bool) lld.cpp:0:0
#14 0x0000000001ab28ff main
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1ab28ff)
#15 0x00007f6e62141d0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#16 0x0000000001ab26aa _start
(/usr/local/google/home/thakis/src/chrome/src/out/gnmac/../../third_party/llvm-build/Release+Asserts/bin/ld64.lld+0x1ab26aa)
clang: error: unable to execute command: Aborted




However, I can't get it to repro running that command in isolation.

Here's a repro file
https://drive.google.com/file/d/1si1bnjCaYBRpykPLn5QlDXK0GoExAhGg/view?usp=sharing&resourcekey=0-zcAJLnHVA8mFMOTaCpf7kA
but I'm not sure how useful it is. Maybe with asan or valgrind?


Jez, that's in your code :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210423/5aaa1abb/attachment-0001.html>


More information about the llvm-bugs mailing list