From patchwork Mon Apr 15 12:34:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 1923714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=1/EiF56T; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VJ6856gV6z1yZ2 for ; Mon, 15 Apr 2024 22:35:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89EEA3858C60 for ; Mon, 15 Apr 2024 12:35:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.154]) by sourceware.org (Postfix) with ESMTPS id 556E33858D35 for ; Mon, 15 Apr 2024 12:34:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 556E33858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 556E33858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713184494; cv=none; b=Jcr8sQoC+eXM1F00UCesW/aHJles+36/J8kD2RsQmum5gHrJxMH4wjPx4lfyXnyikOdWjEGU1HT2kQhYNTQjsl/UdehrtWBKkN4MJ2IVPtRf/ACldgInSq3/lHHBI6urzVoGH7+3rtPwG9AlUT7ckbXmlfD3QI7TTMBKVzvfNCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713184494; c=relaxed/simple; bh=sBePKAC15wGkI+vRQlXjuJCxZNS4sCASLxzDqn9rrng=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oEMmVq+4kyS6tmM38TPQt2n2hf6ewSR/cjE1HxarKun/MKdQ/Y1eMUOgc3yCsv0+0I7Kee6dCK85DgHo8H97QcTUehwVVdXq81ED/brSOqmvJP4v4WUJ3X3OZxCRixKJIGobMDv1hNKaqe1xjL+8K1AGdA/d/OqYo99BnTJTxVw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 3571F30E41A9; Mon, 15 Apr 2024 14:34:44 +0200 (CEST) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:message-id:date:date :subject:subject:from:from:received:received:received; s= dkim20160331; t=1713184483; x=1714998884; bh=cJXmjGfPlK+FaVxN98F zpPRRUTZlK6T2RI2BC7xhVhg=; b=1/EiF56Tnch9XTx0XxlW73s2sTT7BZvGdSS whS7qtcDpfe8ULDBXlZu61XEvWPfsdr9aHMRa1LS8/cwJPOK//vXG1g5pC6ihP2o X6+t5jLxGIrDt4M1UJjXm+8q8xz97WrUudAjI8gVOSIw++Dt0a36oPFXtIHvKrKX yWwOCVowc+FOANP1Vghd2HOWT+ymd4y9mRRlDenA5HQsXrfV5jtTOAmUmKFItGQ/ x3LixtkE8t/zt4Xxf2RtAlJHFRbfni32Ygc4sMp25b84v5o4J/hT7ZPvW1dAY+wH TFKetQYLIZ5IY5lVZ9BgEYiYt8PYLRl6lCZsU/3ksAwEih3MVjcL2sHSNW16Ih1Q I+4pLwjoz1QORjIsXMI1yjVpTE8y8ewItWutDcYjtoP8UpvFF9S/32bWs2gHxUnF CahGPZNpEZBLXFYYN9yhQ3K9Gs5k/lu/U0Muv0B59IPLjD0/RpoW3bfSrOFnAZVp lSqDJR0bAtbZs1qtg64xa0R7DBvcOZG78CSe4SDtpAmf9TRxcUARAMPP9ImBhD63 jo2q2COG9BTk5FVBrWlnlRZZEzpNoTxAsjKJiGMCuOCLRnHjjRZ4WINKSMOQ17Ca DXZL4lnRc+YaVHp4mKqKF9vrBkq3gFuWfdzZqegzXeqWKQsPn8sSaRfNLJ5tNl+1 hAPD5IhY= X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id UoOzlchHN31f; Mon, 15 Apr 2024 14:34:43 +0200 (CEST) Received: from int-mx011.mykolab.com (unknown [10.9.13.11]) by mx.kolabnow.com (Postfix) with ESMTPS id D9F1B30E41A6; Mon, 15 Apr 2024 14:34:42 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx011.mykolab.com (Postfix) with ESMTPS id 9717C31236E3; Mon, 15 Apr 2024 14:34:42 +0200 (CEST) From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz, ro@CeBiTec.Uni-Bielefeld.DE, =?utf-8?q?J=C3=B8rgen_Kvals?= =?utf-8?q?vik?= Subject: [PATCH] Guard longjmp in test to not inf loop [PR114720] Date: Mon, 15 Apr 2024 14:34:34 +0200 Message-Id: <20240415123434.578315-1-j@lambda.is> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Guard the longjmp to not infinitely loop. The longjmp (jump) function is called unconditionally to make test flow simpler, but the jump destination would return to a point in main that would call longjmp again. The longjmp is really there to exercise the then-branch of setjmp, to verify coverage is accurately counted in the presence of complex edges. PR gcov-profile/114720 gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-22.c: Guard longjmp to not loop. --- gcc/testsuite/gcc.misc-tests/gcov-22.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.misc-tests/gcov-22.c b/gcc/testsuite/gcc.misc-tests/gcov-22.c index 641791a7223..7ca78467ca3 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-22.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-22.c @@ -87,7 +87,19 @@ setdest () void jump () { - longjmp (dest, 1); + /* Protect the longjmp so it will only be done once. The whole purpose of + this function is to help test conditions and instrumentation around + setjmp and its complex edges, as both branches should count towards + coverage, even when one is taken through longjmp. If the jump is not + guarded it can cause an infinite loop as setdest returns to a point in + main before jump (), leading to an infinite loop. See PR + gcov-profile/114720. */ + static int called_once = 0; + if (!called_once) /* conditions(suppress) */ + { + called_once = 1; + longjmp (dest, 1); + } } int