Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by mx.groups.io with SMTP id smtpd.web09.57.1617897703399604215 for ; Thu, 08 Apr 2021 09:01:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qa0rIAxu; spf=pass (domain: gmail.com, ip: 209.85.218.52, mailfrom: martin.jansa@gmail.com) Received: by mail-ej1-f52.google.com with SMTP id r12so3941640ejr.5 for ; Thu, 08 Apr 2021 09:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vmYJ061AeOkcFSTyJ9X941UvpAlZmVL74wwYdh7xFqM=; b=Qa0rIAxuPMvNg62OY5RbG+Lc5niiYoYeyYq5fsO2bakXfjPOPCcpmApqNb1LnB7HCV ytJIttgTviFJHCAnaI9XZA79Glnw9payT2BPB3rGH9I6hQxjlmd0qQ7DNfW26atJXfrZ tKpAPE8vpX1Y3PrG1/RuU8rvvFrZfVdyFhRhyMPtfTO9zql90/zsZomWWO2lOVrsRmLy P2KVuTNvhFdcuDuIq8Nv79BHfg5Q3c8GvQd19h8w72H4fPtAVUBR2BC3aTySw8MnCn3a WFskpigM6AZgAj324S1v7gPNIaPCr3puQarfPSESuzZZ7HA15IGEuHTW+LzL3B4qMBAt NlyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vmYJ061AeOkcFSTyJ9X941UvpAlZmVL74wwYdh7xFqM=; b=mDPkWkvmWt6a08SOR5EsoY4+PI3oW2VChg3Bk3ar/6cs9jwmvvCPm088ED8+ZlmIrV JAtFpsv3BRVsURYwtNE2HhPstyhAMnBP9pHvJezI+WM1aphZKq6Xy2CO9e7gFsoCWL1L 8kgZOXLDOMpkQrRnFgQPfvcxgLJ0GFUF1ioAJ9pm+6NSd077cn22Gv2E8Q50OKI8dYFG rh6tdHnlDG/8b+u/VMPJrw28rbETp1kbGsjMmtc2TF6pKFT8TgvjwcuRoNm3dLF1uVJ/ A69TFOhrSSck5MOPPefxspmO/ta1LBavqhYjDjpd4sdblAqNf9laUmIRpvXusQdabO/L h+Zg== X-Gm-Message-State: AOAM530lcXslcR0XmVvPaFy7rbN+ynBe/kM/2Fw4ac2mJRsLL4cRTTRP u9RHVTX/Krtf6KvMHAgaGyYClmsSM40= X-Google-Smtp-Source: ABdhPJyRSh/esaj/xH2TOf+FGvvIBJZw3SL3tEJMyXpoCVZF6q5qZGGxE2gM4E8v61Cc/oiEdTRvFg== X-Received: by 2002:a17:906:714a:: with SMTP id z10mr11277243ejj.455.1617897701752; Thu, 08 Apr 2021 09:01:41 -0700 (PDT) Return-Path: Received: from localhost (ip-109-238-218-228.aim-net.cz. [109.238.218.228]) by smtp.gmail.com with ESMTPSA id c19sm1629973edv.49.2021.04.08.09.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 09:01:41 -0700 (PDT) From: "Martin Jansa" X-Google-Original-From: Martin Jansa To: openembedded-core@lists.openembedded.org Cc: anibal.limon@linaro.org, Martin Jansa Subject: [gatesgarth][PATCH] binutils: backport fix for gold with theads enabled from 2.36.0 Date: Thu, 8 Apr 2021 18:01:38 +0200 Message-Id: <20210408160138.240195-1-Martin.Jansa@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit * building chromium with gold and threads triggers this issue: [1/2] SOLINK ./libcbe.so FAILED: libcbe.so libcbe.so.TOC python "../../git/src/build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libcbe.so" --tocfile="./libcbe.so.TOC" --output="./libcbe.so" -- i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=chromium/84.0.4147.89-4-r41.1/recipe-sysroot -shared -Wl,-soname="libcbe.so" -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -fuse-ld=gold -Wl,--threads -Wl,--thread-count=4 -m32 -Wl,-O2 -Wl,--gc-sections -rdynamic --sysroot=../../recipe-sysroot -L../../recipe-sysroot/lib -L../../recipe-sysroot/usr/lib -Lchromium/84.0.4147.89-4-r41.1/recipe-sysroot -o "./libcbe.so" @"./libcbe.so.rsp" collect2: fatal error: ld terminated with signal 11 [Segmentation fault] compilation terminated. * removing threads/thread-count is one possible work around, but then the use of gold for performance makes even less sense, that's why chromium from meta-browser uses LLD by default: https://github.com/OSSystems/meta-browser/commit/15228b01903d4ca801916e55c7618fa5a71019b7 https://lld.llvm.org/#performance but lets backport this as other recipes might also reproduce this issue Signed-off-by: Martin Jansa --- .../binutils/binutils-2.35.1.inc | 1 + ..._counts_lock-is-initialized-before-u.patch | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch diff --git a/meta/recipes-devtools/binutils/binutils-2.35.1.inc b/meta/recipes-devtools/binutils/binutils-2.35.1.inc index 775af2b8f2..6290d5b191 100644 --- a/meta/recipes-devtools/binutils/binutils-2.35.1.inc +++ b/meta/recipes-devtools/binutils/binutils-2.35.1.inc @@ -44,5 +44,6 @@ SRC_URI = "\ file://0017-gas-improve-reproducibility-for-stabs-debugging-data.patch \ file://0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch \ file://CVE-2020-35448.patch \ + file://0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch \ " S = "${WORKDIR}/git" diff --git a/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch b/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch new file mode 100644 index 0000000000..f46415f440 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch @@ -0,0 +1,41 @@ +From de24fc96bf24fca470a9ca13176ad9ad9cc4d5a9 Mon Sep 17 00:00:00 2001 +From: Nick Gasson +Date: Mon, 2 Nov 2020 12:02:05 +0800 +Subject: [PATCH] gold: ensure file_counts_lock is initialized before using + +Since upgrading to binutils 2.35 I've been experiencing random memory +corruption related crashes with ld.gold --threads. It's caused by +multiple threads concurrently pushing elements onto the shared +std::vector in File_read::record_file_read(). This vector is supposed to +be protected by file_counts_lock, but that is initialized lazily and +might be NULL when File_read::open() is called, in which case +Hold_optional_lock silently skips locking it. + +Fix by calling the initialize() method before attempting to acquire the +lock, the same as other places that use file_counts_lock. + + PR 26827 + * fileread.cc (File_read::open): Ensure file_counts_lock is + initialized. + * testsuite/Makefile.am (check_PROGRAMS): Add a test that passes + -Wl,--threads. + * testsuite/Makefile.in: Regenerate. + +Upstream-Status: Backport [af61e84fd2d from 2.36.0] +Signed-off-by: Martin Jansa +--- + gold/fileread.cc | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gold/fileread.cc b/gold/fileread.cc +index f5ca719360d..0b5228e2afd 100644 +--- a/gold/fileread.cc ++++ b/gold/fileread.cc +@@ -212,6 +212,7 @@ File_read::open(const Task* task, const std::string& name) + gold_debug(DEBUG_FILES, "Attempt to open %s succeeded", + this->name_.c_str()); + this->token_.add_writer(task); ++ file_counts_initialize_lock.initialize(); + Hold_optional_lock hl(file_counts_lock); + record_file_read(this->name_); + } -- 2.30.2