From patchwork Sat Apr 29 13:13:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 68546 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 447FC385609B for ; Sat, 29 Apr 2023 13:15:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 447FC385609B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682774106; bh=wTAfen2SfpNBGuoKNSSnvaxSOX+jRZbcsenC0IC1Nwc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=s4kAdMH8rq0p4mU71wF1BsBpJ1fp0aU1Ht/wvZPM13ex1562jDvwdCfOKVp/XKrV8 ezJbsk3oqrb8OfQSx7bFA/JoEA1j88LsoSsvn2+vPq+/gbn218bkolTL/E1D+LbK5z VMWWH4FjHlhFeHWdYIx0nia0OnCtlDpMIw22RZRI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f004943558so1120566e87.3 for ; Sat, 29 Apr 2023 06:14:00 -0700 (PDT) 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) 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 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 ());