From nobody Wed Apr 16 17:14:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676863523; cv=none; d=zohomail.com; s=zohoarc; b=H/PWXVPeIhXqP0KPLn27EESpKCmSNv3NiPLqlAAwoIrP3oKaW8ENj9PeuurX05fTYxUT5+NLRqbMyhTxvOwXfMsXtJjw4ixB2j7O+UE2R6dpquiuxoJ/Zzuy/9iqlFAa5Fd/pXJrpvpLHlhH/R8bMa/aoa1Xh8NBByUp/3pHhV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676863523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=ImzV5ZGFV+Uy13Xk1nfAzGjSzYM3w0+k1d73Fbw16b95xo10AUjPqhG/Ppog+BuEOqSMNaPk7Sb8LjuqNSF7rYVpyCHqYJz803YmCOP4jSnZyDrDfvUW0vZOrCYy/H06KnwgeDEnMINzRMWIm+MlnI0ck7kURb4dW6EHT2wA7s4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16768635234713.1547108575675793; Sun, 19 Feb 2023 19:25:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pTwmV-0001Bb-GN; Sun, 19 Feb 2023 22:23:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTwmT-0001BL-O4 for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:57 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pTwmS-0005r1-3S for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:57 -0500 Received: by mail-pj1-x1029.google.com with SMTP id o17-20020a17090ab89100b002349a303ca5so1791277pjr.4 for ; Sun, 19 Feb 2023 19:23:55 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id l11-20020a170902d34b00b00198e1bc9d83sm6621302plk.266.2023.02.19.19.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 19:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=XxN1MgoxJd+U40U4KikY3FrdJHZe589HIYBw2KbcFVTsXOSHr947bsO/hYW81ogxaM 0YPWov4BhN37Ze4ehJsn+9pBNfPZZnayfudgoV5Vqxw4UwnyI0sHOrp7NXs7xD2t0bjF z9AxvXyG1SA+jsR68THjoSEInFg51zg8RNVCian6a02l4lgh+wDNsxqTTTekgt00MpYB Lri8SOiAlZPxbZdwYRU/CIW01+eZ4fM/4aX1ufBOo+OpszIQvyH0P0iTEw7SZRbutJUq jJYZ0VYPfPxtpB3r1YfcTo1m2Gwdkbcx//1rZeufODgZe2gIz4BJjh8JOe4vPFef9uoX L9zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=MofwVnMCuw4hkFbeBZ5yJ969s44fHysU+4GLpO+tlOE0E6KLG9EOa6PUiicGnIFt9E OJpkQbNafnFEjSpI1BGK05xqntQM1gPxettutCsV5j5p2JmQKnbnH1ODrcmiANzPxTkX WH0Cc3EJsi1zX62oiKi9YWNB0RdX4Jlb8Dc/MAr1pXiEUokSNe4GB18JuWXNzRAloNPy GqfJbZH9nZafpDVDfmFAG+vslOBg69kJALu+BRBPs38OMeoq8boI6PxnB43rRhQEjkyN CmtsBDH1wW2YFzye/Of5KdDbjcoRCQGhFyus4FrMS+TBUzmVEZqWgDm53yEFbMsker0k 8rrA== X-Gm-Message-State: AO0yUKWHj89zascypSFmzuG9C1SX9WHKHbEIHSvbaNuUwzexJCay4QuL 43jL9I8g7eBzX+RlJxI4X0S8lZozfRoskJpTpJw= X-Google-Smtp-Source: AK7set9uxK+HDTJoRdsXkkbD997dMEu5rZ7VDDAc65WLhr597mRiurSSYIHvB3w9RuUpRzEV1w+b/g== X-Received: by 2002:a17:902:c408:b0:19a:9984:5590 with SMTP id k8-20020a170902c40800b0019a99845590mr1393472plk.5.1676863434603; Sun, 19 Feb 2023 19:23:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 6/7] tests/tcg/linux-test: Add linux-fork-trap test Date: Sun, 19 Feb 2023 17:23:37 -1000 Message-Id: <20230220032338.5619-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220032338.5619-1-richard.henderson@linaro.org> References: <20230220032338.5619-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676863523870100002 From: Ilya Leoshkevich Check that dying due to a signal does not deadlock. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Message-Id: <20230214140829.45392-5-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/multiarch/linux/linux-fork-trap.c | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-fork-trap.c diff --git a/tests/tcg/multiarch/linux/linux-fork-trap.c b/tests/tcg/multia= rch/linux/linux-fork-trap.c new file mode 100644 index 0000000000..2bfef800c3 --- /dev/null +++ b/tests/tcg/multiarch/linux/linux-fork-trap.c @@ -0,0 +1,51 @@ +/* + * Test that a fork()ed process terminates after __builtin_trap(). + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include + +int main(void) +{ + struct rlimit nodump; + pid_t err, pid; + int wstatus; + + pid =3D fork(); + assert(pid !=3D -1); + if (pid =3D=3D 0) { + /* We are about to crash on purpose; disable core dumps. */ + if (getrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + nodump.rlim_cur =3D 0; + if (setrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + /* + * An alternative would be to dereference a NULL pointer, but that + * would be an UB in C. + */ + printf("about to trigger fault...\n"); +#if defined(__MICROBLAZE__) + /* + * gcc emits "bri 0", which is an endless loop. + * Take glibc's ABORT_INSTRUCTION. + */ + asm volatile("brki r0,-1"); +#else + __builtin_trap(); +#endif + } + err =3D waitpid(pid, &wstatus, 0); + assert(err =3D=3D pid); + assert(WIFSIGNALED(wstatus)); + printf("faulting thread exited cleanly\n"); + + return EXIT_SUCCESS; +} --=20 2.34.1