From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) by sourceware.org (Postfix) with ESMTPS id 99DCE385734E for ; Tue, 27 Sep 2022 07:15:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99DCE385734E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andestech.com Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 28R7Fftw027948; Tue, 27 Sep 2022 15:15:41 +0800 (+08) (envelope-from ycliang@andestech.com) Received: from ubuntu01 (10.0.12.75) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Tue, 27 Sep 2022 15:15:38 +0800 Date: Tue, 27 Sep 2022 07:15:12 +0000 From: Leo Liang To: Florian Weimer CC: , , , Subject: Re: Is it reasonable to expect errno to be 0 when entering main? Message-ID: References: <87mtalz71b.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <87mtalz71b.fsf@mid.deneb.enyo.de> User-Agent: Mutt/2.0.5 (2021-01-21) X-Originating-IP: [10.0.12.75] X-DNSRBL: X-MAIL:Atcsqr.andestech.com 28R7Fftw027948 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Florian, On Tue, Sep 27, 2022 at 08:05:20AM +0200, Florian Weimer wrote: > * 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. Will do! Thanks for the timely response! Besides, Do you have any suggestion as to how this could be fixed? We could try send out a patch as well! Best regards, Leo