From nobody Thu Feb 08 19:26:26 2024 X-Original-To: dev-commits-src-branches@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 4TW6RQ3PZfz5BFKW; Thu, 8 Feb 2024 19:26:26 +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 4TW6RQ2Qnrz4p6y; Thu, 8 Feb 2024 19:26:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707420386; 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=o0YfCgoNXXSEedEEtW9A12QWwCsy9SUbFPvyObI2ELA=; b=KBIUojA7mHNHVyOPWSKeBwQ8grwwCUko2aE1ArO+XrJO7LWmfOGL0mlQM50zhOf5mFzbQF tM+6er37xDgVWJwsNFDxRXYTFxrbe+Xba2Dycvc1cUi+2b1SrmallvAYHhLmjwwih01ZU+ bp2WZ6OGs+tsNd3gbGbD5MNdkRMcLtnsOE3t78HOS+7/VraF12rIM0R2fsb0SBNS746EdM zOeKjRHQIti+yhq/1dHTO3MeizfJzf1r/IBN27x5EPHnOmKCp92S95h69GdnjjY/rjNX1m kQb4JcI+OWhgZdDkURS8BYaSiuiAEhRnHaDdsFFmcvuMd6MQDDaYbdhrMhiB7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707420386; 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=o0YfCgoNXXSEedEEtW9A12QWwCsy9SUbFPvyObI2ELA=; b=ImPI6OvRh6UvzRskTuJbVwd5l641VbnonqBGnD5ndzNuGv/qafInVCMqO23kVyyccEVN8y 08JICCTQcECIyg9VTyU+Fi8yL1MIWDEkXqzGxGbaQEa20aJbEq+Jq3WHo47auV91NwWFTF z1BNR57sd8cUskxpHIOokgLfKvF4qWsDA72z5vhi7P/SPg7TR9mZ2Z+i4KBPB0DKm4NKIU OQtgSyNrnNRJ90pwIzS47qRYY6sIUc67CSv9bgoTPzReJu2WbKsS4VjLVafCFtEGDyIH7O so1KnODd8/dfB6bp/zHuhHSibBr+Tdd9cFmaSP+YfqyUFj2NFNxknT2PL0vXgg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707420386; a=rsa-sha256; cv=none; b=IY5Rq17VFeU2YjElFNf7q9Oe3T1s4Zlormd33xSY9t4+sA094X+ZVMLQ6+8yA30iIoDz8r yLD++W5xjiUEWFMronO62/DpyTetKSbdRSNJL477/A9adL1TBSX3DZnmbti+U4Zfm7XYAf jw+6nUqD2mtpKzwhWpEUdYgu2JKpi60vj87plVzNsCtW+KhaPhFKuVB54Pdl6TzxyQO7VQ 9rMaeJXe6ovRfThbqSCsZ3WhEPHLWcM01JmDtPYCROvxbu1ViQB2CYLF5ClSfBbogWBR9e pQ8Ets74od+uY2LfYoy09xZ44SR9yYz9FRTULrElbJj80OS68Osr2/RWhXgp1A== 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 4TW6RQ1VTpz12yy; Thu, 8 Feb 2024 19:26:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 418JQQvY009051; Thu, 8 Feb 2024 19:26:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 418JQQBW009048; Thu, 8 Feb 2024 19:26:26 GMT (envelope-from git) Date: Thu, 8 Feb 2024 19:26:26 GMT Message-Id: <202402081926.418JQQBW009048@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: 6d5c1c562cc5 - stable/14 - Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 6d5c1c562cc58ee31022df56b853d92173e1fbc1 Auto-Submitted: auto-generated The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=6d5c1c562cc58ee31022df56b853d92173e1fbc1 commit 6d5c1c562cc58ee31022df56b853d92173e1fbc1 Author: Dimitry Andric AuthorDate: 2024-01-25 17:41:44 +0000 Commit: Dimitry Andric CommitDate: 2024-02-08 19:26:04 +0000 Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba Interesting fixes (* were already cherry-picked): - 03c83f5 add __cxa_init_primary_exception (#23) * 5d8a158 Fix two bugs in __cxa_end_cleanup() * b00c6c5 Insert padding in __cxa_dependent_exception * 45ca8b1 Insert padding in __cxa_exception struct for compatibility * f2e5509 Fix unlock in two-word version and add missing comment. - 6229590 Add an option for disabling emergency buffers. (#14) MFC after: 2 weeks (cherry picked from commit ecf4106237505fa9459ae871793b754334989c17) --- contrib/libcxxrt/cxxabi.h | 8 ++++++++ contrib/libcxxrt/exception.cc | 44 +++++++++++++++++++++++++++++++++++-------- lib/libcxxrt/Version.map | 4 ++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/contrib/libcxxrt/cxxabi.h b/contrib/libcxxrt/cxxabi.h index e843599c66da..e021f85c905a 100644 --- a/contrib/libcxxrt/cxxabi.h +++ b/contrib/libcxxrt/cxxabi.h @@ -203,6 +203,14 @@ __cxa_eh_globals *__cxa_get_globals_fast(void); std::type_info * __cxa_current_exception_type(); + +void *__cxa_allocate_exception(size_t thrown_size); + +void __cxa_free_exception(void* thrown_exception); + +__cxa_exception *__cxa_init_primary_exception( + void *object, std::type_info* tinfo, void (*dest)(void *)); + /** * Throws an exception returned by __cxa_current_primary_exception(). This * exception may have been caught in another thread. diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc index 6c5196876b10..b1659c902f56 100644 --- a/contrib/libcxxrt/exception.cc +++ b/contrib/libcxxrt/exception.cc @@ -162,6 +162,7 @@ struct __cxa_thread_info terminate_handler terminateHandler; /** The unexpected exception handler for this thread. */ unexpected_handler unexpectedHandler; +#ifndef LIBCXXRT_NO_EMERGENCY_MALLOC /** * The number of emergency buffers held by this thread. This is 0 in * normal operation - the emergency buffers are only used when malloc() @@ -170,6 +171,7 @@ struct __cxa_thread_info * in ABI spec [3.3.1]). */ int emergencyBuffersHeld; +#endif /** * The exception currently running in a cleanup. */ @@ -445,6 +447,23 @@ extern "C" __cxa_eh_globals *ABI_NAMESPACE::__cxa_get_globals_fast(void) return &(thread_info_fast()->globals); } +#ifdef LIBCXXRT_NO_EMERGENCY_MALLOC +static char *alloc_or_die(size_t size) +{ + char *buffer = static_cast(calloc(1, size)); + + if (buffer == nullptr) + { + fputs("Out of memory attempting to allocate exception\n", stderr); + std::terminate(); + } + return buffer; +} +static void free_exception(char *e) +{ + free(e); +} +#else /** * An emergency allocation reserved for when malloc fails. This is treated as * 16 buffers of 1KB each. @@ -584,6 +603,7 @@ static void free_exception(char *e) free(e); } } +#endif /** * Allocates an exception structure. Returns a pointer to the space that can @@ -773,6 +793,21 @@ static void throw_exception(__cxa_exception *ex) report_failure(err, ex); } +extern "C" __cxa_exception *__cxa_init_primary_exception( + void *object, std::type_info* tinfo, void (*dest)(void *)) { + __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(object) - 1; + + ex->referenceCount = 0; + ex->exceptionType = tinfo; + + ex->exceptionDestructor = dest; + + ex->unwindHeader.exception_class = exception_class; + ex->unwindHeader.exception_cleanup = exception_cleanup; + + return ex; +} + /** * ABI function for throwing an exception. Takes the object to be thrown (the @@ -783,15 +818,8 @@ extern "C" void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void(*dest)(void*)) { - __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1; - + __cxa_exception *ex = __cxa_init_primary_exception(thrown_exception, tinfo, dest); ex->referenceCount = 1; - ex->exceptionType = tinfo; - - ex->exceptionDestructor = dest; - - ex->unwindHeader.exception_class = exception_class; - ex->unwindHeader.exception_cleanup = exception_cleanup; throw_exception(ex); } diff --git a/lib/libcxxrt/Version.map b/lib/libcxxrt/Version.map index 0d2dccbe2670..a54b6a4daad5 100644 --- a/lib/libcxxrt/Version.map +++ b/lib/libcxxrt/Version.map @@ -283,6 +283,10 @@ CXXABI_1.3.9 { }; } CXXABI_1.3.6; +CXXABI_1.3.11 { + __cxa_init_primary_exception; +} CXXABI_1.3.9; + CXXRT_1.0 { extern "C++" {