From nobody Sat Dec 25 11:55:42 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F1A1E18F30DC; Sat, 25 Dec 2021 11:55:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JLj735GGmz4lFj; Sat, 25 Dec 2021 11:55:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9418216E86; Sat, 25 Dec 2021 11:55:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BPBtgmF006662; Sat, 25 Dec 2021 11:55:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBtge7006661; Sat, 25 Dec 2021 11:55:42 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:42 GMT Message-Id: <202112251155.1BPBtge7006661@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 456e2b149ecb - stable/12 - Apply upstream lldb fix for unhandled Error causing abort List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 456e2b149ecb1ea5f9e81b9b0733c7ec9526b8c2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vv9K1qGGL0fzDoZJgW4Ewc4vyyqsnDKcjzqLz9SEzek=; b=W/W0CaheBYeSY1w+c6trvLD4IM0EOeGwehMOgM/aB4bCf2UQhbSBAI9i3rUSfEWAnAVa7K LqgoFUIlX2MF0X1n/y44vGVEQnH8goCdJ8rdXtGGXud/365fOe+3/Wmn4ifJ11UoFpOzLw mITLyWeOqFFJN89eKHtRF3R6OKHn8Qjy0sS5Wr0wTzuUO74dAFww5PYV/ufTtoMO3fsFbo UUOMfDUmVNs99noEMyz4dFKCwZCAeBczR3L7aBBVGBE6/9TXz9n/CXZfaaKfjn8w9cbS72 MU3GiGbwKIGJbRD7HRGy+vZxv1LIWYclLDbvMV8HkcrgsGmcsDPGEwgxytjfYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433345; a=rsa-sha256; cv=none; b=UXwYQnJYM8gZ/XKl4pkRrllrUhqeLX9zYitsvSd+NNAac08jKI5/Jcl64G4ZzKmm7WtvfQ SPSDG/H4LBVXld62p2JckwzUJV7iZvrvcY7gU29Uy4sNxHszY7csSVK1v38Sf+gv0LylvN O/KxYHwa8T/N9r5YLxX2S9qb5J6SkOR//Imudp4vCZeNXg4FlruhSWCEm4Vp2HQxTa3wPa CN52LmJ60LVOca37sS8aKF7+R7TqBMYgjd6ZJKXyqjtz+EpS5717xdmQSDrnMLbxeGpixn eslICvbdqxwbusbAViPtgNFLLFEPatg6PknWOuH/SSIKV2m0dp8CLCQfKLF7HQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=456e2b149ecb1ea5f9e81b9b0733c7ec9526b8c2 commit 456e2b149ecb1ea5f9e81b9b0733c7ec9526b8c2 Author: Dimitry Andric AuthorDate: 2021-08-16 16:56:41 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:16 +0000 Apply upstream lldb fix for unhandled Error causing abort Merge commit 5033f0793fe6 from llvm git (by Dimitry Andric): [lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage When assertions are turned off, the `llvm::Error` value created at the start of this function is overwritten using the move-assignment operator, but the success value is never checked. Whenever a TypeSystem cannot be found or created, this can lead to lldb core dumping with: Program aborted due to an unhandled Error: Error value was Success. (Note: Success values must still be checked prior to being destroyed). Fix this by not creating a `llvm::Error` value in advance, and directly returning the result of `llvm::make_error` instead, whenever an error is encountered. See also: and . Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D108088 Reported by: dmgk, ota@j.email.ne.jp PR: 253881, 257829 MFC after: 3 days (cherry picked from commit c1a540709a83f810aa47380b946552ab20020374) --- .../llvm-project/lldb/source/Symbol/TypeSystem.cpp | 90 +++++++++------------- 1 file changed, 38 insertions(+), 52 deletions(-) diff --git a/contrib/llvm-project/lldb/source/Symbol/TypeSystem.cpp b/contrib/llvm-project/lldb/source/Symbol/TypeSystem.cpp index 2adf36fa8276..83161f32444c 100644 --- a/contrib/llvm-project/lldb/source/Symbol/TypeSystem.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/TypeSystem.cpp @@ -224,62 +224,32 @@ void TypeSystemMap::ForEach(std::function const &callback) { llvm::Expected TypeSystemMap::GetTypeSystemForLanguage( lldb::LanguageType language, llvm::Optional create_callback) { - llvm::Error error = llvm::Error::success(); - assert(!error); // Check the success value when assertions are enabled std::lock_guard guard(m_mutex); - if (m_clear_in_progress) { - error = llvm::make_error( + if (m_clear_in_progress) + return llvm::make_error( "Unable to get TypeSystem because TypeSystemMap is being cleared", llvm::inconvertibleErrorCode()); - } else { - collection::iterator pos = m_map.find(language); - if (pos != m_map.end()) { - auto *type_system = pos->second.get(); - if (type_system) { - llvm::consumeError(std::move(error)); - return *type_system; - } - error = llvm::make_error( - "TypeSystem for language " + - llvm::StringRef(Language::GetNameForLanguageType(language)) + - " doesn't exist", - llvm::inconvertibleErrorCode()); - return std::move(error); - } - for (const auto &pair : m_map) { - if (pair.second && pair.second->SupportsLanguage(language)) { - // Add a new mapping for "language" to point to an already existing - // TypeSystem that supports this language - m_map[language] = pair.second; - if (pair.second.get()) { - llvm::consumeError(std::move(error)); - return *pair.second.get(); - } - error = llvm::make_error( - "TypeSystem for language " + - llvm::StringRef(Language::GetNameForLanguageType(language)) + - " doesn't exist", - llvm::inconvertibleErrorCode()); - return std::move(error); - } - } + collection::iterator pos = m_map.find(language); + if (pos != m_map.end()) { + auto *type_system = pos->second.get(); + if (type_system) + return *type_system; + return llvm::make_error( + "TypeSystem for language " + + llvm::StringRef(Language::GetNameForLanguageType(language)) + + " doesn't exist", + llvm::inconvertibleErrorCode()); + } - if (!create_callback) { - error = llvm::make_error( - "Unable to find type system for language " + - llvm::StringRef(Language::GetNameForLanguageType(language)), - llvm::inconvertibleErrorCode()); - } else { - // Cache even if we get a shared pointer that contains a null type system - // back - TypeSystemSP type_system_sp = (*create_callback)(); - m_map[language] = type_system_sp; - if (type_system_sp.get()) { - llvm::consumeError(std::move(error)); - return *type_system_sp.get(); - } - error = llvm::make_error( + for (const auto &pair : m_map) { + if (pair.second && pair.second->SupportsLanguage(language)) { + // Add a new mapping for "language" to point to an already existing + // TypeSystem that supports this language + m_map[language] = pair.second; + if (pair.second.get()) + return *pair.second.get(); + return llvm::make_error( "TypeSystem for language " + llvm::StringRef(Language::GetNameForLanguageType(language)) + " doesn't exist", @@ -287,7 +257,23 @@ llvm::Expected TypeSystemMap::GetTypeSystemForLanguage( } } - return std::move(error); + if (!create_callback) + return llvm::make_error( + "Unable to find type system for language " + + llvm::StringRef(Language::GetNameForLanguageType(language)), + llvm::inconvertibleErrorCode()); + + // Cache even if we get a shared pointer that contains a null type system + // back + TypeSystemSP type_system_sp = (*create_callback)(); + m_map[language] = type_system_sp; + if (type_system_sp.get()) + return *type_system_sp.get(); + return llvm::make_error( + "TypeSystem for language " + + llvm::StringRef(Language::GetNameForLanguageType(language)) + + " doesn't exist", + llvm::inconvertibleErrorCode()); } llvm::Expected