From patchwork Fri Feb 16 14:56:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 202149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp566378dyb; Fri, 16 Feb 2024 06:57:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkhwvC1dMq+30gVDvWFOa7yn9s7F2lpirj06sjSyMI1QIB70aVJ7f5fBBaOhZRffr3WyJtv80vLkAx7wonbkPdCpvMlg== X-Google-Smtp-Source: AGHT+IGf6It164iAPGQeBkXUWIIUFMcZq254OmPreRS/f44sHOOBHNwtNmfpXdu6qt4vK77PzPad X-Received: by 2002:a05:620a:8:b0:787:25ca:ddc9 with SMTP id j8-20020a05620a000800b0078725caddc9mr4877363qki.70.1708095448445; Fri, 16 Feb 2024 06:57:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708095448; cv=pass; d=google.com; s=arc-20160816; b=xm68bGj7l/MfO9biB3SWPiVCgqw9hRbuPeMb2mZEPqWM+jiPghL8A9Hd3zFMwuAC81 xWaFHoJYl10ZZDtUjPF+d/y4WpT0M2oz1aN52bQJVLEHGiLmQ/SRegI/xb58j5HpjumV JSA2MKNA/+ISO20jisoEFvvUL9PmephbH+vltcMFoUEVxWAyY3c91O1Rusgpv8nHLpCU 1H2KQf+iB90gS0Xt5gF8HVXXdJDhlUHzCYb9SX0/loJdEcChlXiL/jZBurjCCNiz0g1M pG5/rYAM5kGPwAGpOUjfvx+xDvgC0iMNX7IHhYeHJjKR80t/0WcM8JURpfuM5ArjckWr 6Ubw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=OBHxDe62oF6tG5aygEwlgznKdr1QKGqOUik0bTT9V5k=; fh=9NptTb5xVOnlJO16eqqLDGhKgSSkHIliY4WJ2ae04rg=; b=YvEX1yCShepGBDbVDPQeYpAt3YqB94cAgGSoKx4ZKLz0GnOX5+y1B3QEpX1/zKOoCR rv8M5N4hdtOk8eTzN9wKduon00yGc2nBz8xWNL6Tng4j2P/2/1bt50F+Mnc2sRzz4imV SatrAbAXqYbnYyUugUbGhkOQsEzNW5F2J4PPzc2P48mbuMUoCBv2c9gnZ2o6PpQQsSBx EbhPA1lvWl6/HDmVsUNO5eVG7woMsCyuFvgTjIj4jHGmQqCHhrlyes++cBsES451KCJ+ lmdc9hCv5ib2wMSpY6CZV8lVI0Se0p4GIg9i1myVXvm7xJ1BIs0gzHqfRbMkvGVlio+f TycQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hsBOXhtI; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qs15-20020a05620a394f00b007873af4a4e7si25909qkn.764.2024.02.16.06.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 06:57:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hsBOXhtI; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27EDB3857C4D for ; Fri, 16 Feb 2024 14:57:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 35C5C385829E for ; Fri, 16 Feb 2024 14:56:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35C5C385829E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 35C5C385829E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708095409; cv=none; b=oVyhsxQ9dK/4G/DLLh14UCnpiI67gCSczJg7ntpHwFzJHIn13Oo0H/TPuhOMCGiZmsnUUYu0kdMhwaxv/L+eSykzYd7amBVYmVF8AwbIUpr5LliEX+9d6KLW/uIEThMYtcxVoxd0YWBUJRgenHw2gUHOZE2VYsP6D/lFw2znMOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708095409; c=relaxed/simple; bh=iHVQAzzzfTaTgzOXCLFz1g/OQfWxLf37ORqpX3X1H8Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=vGCn7OpF0rBHVy/V0albnBPISCJwHCaQfHYHh+rOT7ApO+GfdXbMD87ysZIToRbjD6ffCfNyPaGcZ0HGTKOrO1GObp8Qf5VimW7TkbJMsIXB5OPFhpdmqCIJaHN7lR23bDZL+V/glC5hw5168wD7EtCIr131yvuFtx1/qydkfNQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2d1094b5568so28482901fa.1 for ; Fri, 16 Feb 2024 06:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708095405; x=1708700205; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OBHxDe62oF6tG5aygEwlgznKdr1QKGqOUik0bTT9V5k=; b=hsBOXhtIdXKbjiOI41grWD0uRBAxXBWV0WYtamtlsuNm0LWjmHIGJ3LtWd0uHiqFee O2YwgFuKPCRzuU3IGN4mT6Mk6pfvZQoysraiujoM1/KgLE3dwjdXYq5mvkF60d6H6Nk6 V6oj4ZF5m9ss2/QV1L+dWAQ8s126mQS56aH27cTGfj0y6fVLPA0bjEZH/lekBYr3EUke Z0U+uRouE6N2gmYrdmHz48GInxe1z1bah5LvdvjwgFpS5emLA+V+doJCHDPd5eCSD6BY q3T1Kso0oRc0dzOdQ8tyNyJ52C0EtJa+YRieo5xzLAiiO0mG1ZIkIcjWhpSBPfS2QZ2+ do/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708095405; x=1708700205; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OBHxDe62oF6tG5aygEwlgznKdr1QKGqOUik0bTT9V5k=; b=CaO7LLhZvNBsYzmxS73z8rI8z6SXXweM1PdjkHR/AGmB5Ppee3GfIrOVPRZnZbS663 REhp0pV9oNM2t9+NaQV9Ev+CvSAcPShmNZz8zJKe/w2mSO/nWGbeblDBwwf/kVmSILrT rYp3cTu2tLkbUei8vHioY0yfaiwBClCUVdh97L0Mi/azN2vJKOOWfU9Y6Nry57L8QMjD wqFse0aL9gjT9ObYwUD7s0EDr9OAfM2UIcrxHAQq45Iu8IbxzhLOgu5uEAqoBPhYG+1+ FghgHB9WvcCH0ud3VGqQiYef5Uni1D7uS5RZ61aMQ07RvfHRupEuVF2c05IcGOWrAgYx IR+Q== X-Gm-Message-State: AOJu0YxWYh+DECPrJbRUjE0EYwuqet5VVrDccKVvym3/LaoZBfIkNZTb Oy2xIBHaVwEo8jUa2V3YlEA7pZ0UDuHZlqXKZ+tSX9WPA57JWOur56LDOrSc X-Received: by 2002:a2e:9dd4:0:b0:2d0:4c41:695 with SMTP id x20-20020a2e9dd4000000b002d04c410695mr3887147ljj.37.1708095405137; Fri, 16 Feb 2024 06:56:45 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c4ed100b0040ecdd672fasm2669894wmq.13.2024.02.16.06.56.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 16 Feb 2024 06:56:44 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: ian@airs.com Subject: [PATCH] libiberty: Fix error return value in pex_unix_exec_child [PR113957]. Date: Fri, 16 Feb 2024 14:56:43 +0000 Message-Id: <20240216145643.50448-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791067892812509084 X-GMAIL-MSGID: 1791067892812509084 tested on x86_64-darwin, so far. OK for trunk if regression test is successful on Linux too? thanks Iain --- 8< --- r14-5310-g879cf9ff45d940 introduced some new handling for spawning sub processes. The return value from the generic exec_child is examined and needs to be < 0 to signal an error. However, the unix flavour of this routine is returning the PID value set from the posix_spawn{p}. This latter value is undefined per the manual pages for both Darwin and Linux, and it seems Darwin, at least, sets the value to some usually positive number (presumably the PID that would have been used if the fork had succeeded). The fix proposed here is to set the pid = -1 in the relevant error paths. PR other/113957 libiberty/ChangeLog: * pex-unix.c (pex_unix_exec_child): Set pid = -1 in the error paths, since that is used to signal an erroneous outcome for the routine. Signed-off-by: Iain Sandoe --- libiberty/pex-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c index af98062a94c..f3a1cc95ada 100644 --- a/libiberty/pex-unix.c +++ b/libiberty/pex-unix.c @@ -695,6 +695,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, { *err = ret; *errmsg = "posix_spawnp"; + pid = -1; /* The value of pid is unspecified on failure. */ goto exit; } } @@ -705,6 +706,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, { *err = ret; *errmsg = "posix_spawn"; + pid = -1; goto exit; } }