From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id 94CBF3858CDA for ; Tue, 27 Sep 2022 06:05:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94CBF3858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=deneb.enyo.de Received: from [172.17.203.2] (port=57063 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) id 1od3ib-007i4b-65; Tue, 27 Sep 2022 06:05:21 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.94.2) (envelope-from ) id 1od3ia-0004Wg-QP; Tue, 27 Sep 2022 08:05:20 +0200 From: Florian Weimer To: Leo Liang Cc: , peterlin@andestech.com, dylan@andestech.com, alankao@andestech.com Subject: Re: Is it reasonable to expect errno to be 0 when entering main? References: Date: Tue, 27 Sep 2022 08:05:20 +0200 In-Reply-To: (Leo Liang's message of "Mon, 26 Sep 2022 12:07:30 +0000") Message-ID: <87mtalz71b.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP 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: * Leo Liang: > If the above program is statically-linked, and if the program is executed before "crng init done", > the errno will not be zero when entering main. > > There seems to be syscall (__getrandom) before main is entered, > and if the crng is not initialized, the syscall will fail causing the errno to be set. > (_dl_get_origin -> __libc_malloc -> ptmalloc_init -> tcache_key_initialize -> __getrandom) > > So we are wondering if we should set errno to zero before entering main. This is a bug. It only affects static linking. Would you please file it in Bugzilla? Thanks.