From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id B0E003858C30 for ; Sat, 29 Apr 2023 13:14:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0E003858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f004943558so1120566e87.3 for ; Sat, 29 Apr 2023 06:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682774039; x=1685366039; 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=wTAfen2SfpNBGuoKNSSnvaxSOX+jRZbcsenC0IC1Nwc=; b=JYJcYvABMlNVZBW3xHcfApt5iFWj+Su6wRXb5rPCsy+Aqd86b0Qsqe8Nug61RGeo8w +Edi0GkAvKN34+JFGk6xKFvYmUEg1QFeT/ZlLUZ+dXz6CsllRudf/7+uZbKi1MxaYA2X Z3xts6Jv4Aamc4+855t0WmLEy/X2ti3eXXXCCOGVLPp0eF8RCrMnKVdVSWblzF32OX+t VEjmQWwSN3se5YoVEQlGb7DXT/QkECy6V71qoIXhT11epixpHH7angqFAwSwciwZfZWQ UKSWFn8vaasjRLgA2NHZE+RZ/rBR+R2B+4pgqPrVm3OFKUNqEDlRHRHmBOueiP1tT+nV LH+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682774039; x=1685366039; 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=wTAfen2SfpNBGuoKNSSnvaxSOX+jRZbcsenC0IC1Nwc=; b=EfniFbEi7vfMhimyGeLz8xLbKtGgqrLgQj2ZW7lZvhrWFp7d64u6P+TFosbw3F+Kfq VSQccBKiuCwPSWD1Vj5TnOOjlP/tlNmaAXC9xPu0PJOjz3Y548aVKt7iQxCW6IR6iL9D n3HrLlNj2w60Ji3gCxS2NmbkYo+LZjuLrOVw9I3WAqz4l5T5fxDWyLBV6Md3UN6iqf2B sp+YvclgKo5/NdQn4p1Q9N53yT3TiCbOU8/3GXDtpTN2CxGCRY+k6Mm58QyjJ7hYtAGi WemBDdLizHoSEw94/mUKjm0I7539Ud9oq5A/AD0T+1OXPcWClplyhIvC7fQob/4+c6+q FXXQ== X-Gm-Message-State: AC+VfDzr7G3y3O0PybGLsllAoFqdlVmETUfkd/id8FR/LZa9LYJeF3LR HdcTFfIlkPZ+qispq9FofQWZQGSzYBPJqA== X-Google-Smtp-Source: ACHHUZ6bY5STQhXOyiw5iNC+i3pEiNg9UHWdYB2eyE0MmhxLDdodXWs0pWN5lECkBeQiMMeS9QeXRA== X-Received: by 2002:a05:6512:15a:b0:4eb:d8d:6c13 with SMTP id m26-20020a056512015a00b004eb0d8d6c13mr2248439lfo.9.1682774038876; Sat, 29 Apr 2023 06:13:58 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:8a14:19ba:9e6b:1866]) by smtp.gmail.com with ESMTPSA id f27-20020ac251bb000000b004eb018fac57sm3744851lfk.191.2023.04.29.06.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Apr 2023 06:13:58 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org Cc: bug-hurd@gnu.org, Samuel Thibault Subject: [PATCH 4/7] hurd: Make _exit work during early boot-up Date: Sat, 29 Apr 2023 16:13:51 +0300 Message-Id: <20230429131354.2507443-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230429131354.2507443-1-bugaevc@gmail.com> References: <20230429131354.2507443-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 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 List-Id: If any of the early boot-up tasks calls exit () or returns from main (), terminate it properly instead of crashing on trying to dereference _hurd_ports and getting forcibly terminated by the kernel. We sadly cannot make the __USEPORT macro do the check for _hurd_ports being unset, because it evaluates to the value of the expression provided as the second argument, and that can be of any type; so there is no single suitable fallback value for the macro to evaluate to in case _hurd_ports is unset. Instead, each use site that wants to care for this case will have to do its own checking. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/_exit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/mach/hurd/_exit.c b/sysdeps/mach/hurd/_exit.c index 73957744..80cfe532 100644 --- a/sysdeps/mach/hurd/_exit.c +++ b/sysdeps/mach/hurd/_exit.c @@ -24,8 +24,9 @@ void _hurd_exit (int status) { - /* Give the proc server our exit status. */ - __USEPORT (PROC, __proc_mark_exit (port, status, 0)); + if (_hurd_ports != NULL) + /* Give the proc server our exit status. */ + __USEPORT (PROC, __proc_mark_exit (port, status, 0)); /* Commit suicide. */ __task_terminate (__mach_task_self ()); -- 2.40.1