From owner-svn-src-head@freebsd.org Wed Sep 9 13:44:36 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ABCEE3D169E; Wed, 9 Sep 2020 13:44:36 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BmjtX2YkFz4HCc; Wed, 9 Sep 2020 13:44:36 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qk1-x731.google.com with SMTP id v123so2403836qkd.9; Wed, 09 Sep 2020 06:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Dht25Xtp1iDJgPNGGurDvsEf0YFXQZXrk7srbpy7m9M=; b=uU8KA1TfeKl0WpX6o+NYz232Ru+dMAaLe7eC93YzbqwCway1uL2HiicLzLttmd5k5o l4GnqBo7MZ3ZLD5JxevNve0C74P7OMKhk2VYeYC5t5W1fjg5Psp2lCo4uPKuIahYBEc0 BoJzFI4frfHJl4MttqHQj/+IGITDVRVtMcW/gRLSa8vWMFhM62YLSQvSET8Re3mFmpjR DZgXoRJbSq0tPHWHWVS7t6UC8LlRNdNIFj6sTshmWIm+XYsrpGPirp161xb6dMXJYSS9 9Zi2rfYc6wYQSiChDTv1SOwW8/8dc5zfJYu01oQ15vNz980+7mo+H1On0cCGug2+03Em k7UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=Dht25Xtp1iDJgPNGGurDvsEf0YFXQZXrk7srbpy7m9M=; b=Kz8yysa2YA8tRLvbWhCkxMf84dZ7QsrSQGxl1R2lBwl6kjsTJDhy+npuKHXACbo7jL AJtCkQpC9kosqV528qds7DDFTEpcSzuzPUnKiETCBkNaLaiCUwetiyoWPbtiZ3hAO3vO 5/kvapMoeGwzjsyNS9Zn6QKD7xld/wNgdxTBUsRSjtZAHELh6cCGh25xQO4pBhifsn7R 2Pl+LoQ3CJDLwaRXD4lHz/dmkKh9E6TKR1qi2YQ/sPaJxUTTmNaDVCxAqkQjntAplN7D 9RYGJ2hVga2KyYMbizxO2sDtUEp7Eo2CQ5UKjUVDapyIxN5V+5Edot63ls2g+bX8pMBs sxpw== X-Gm-Message-State: AOAM530aaqGZULyoYwfQ5+t5R2zO3W2KVrypgppHvZOiXDsZzaOjzpBp lUfng87zZOwXAUON1D+zyTo/lW6PSqSTBw== X-Google-Smtp-Source: ABdhPJzktjG6TzJYXjDE+L4i2djk4xH3CGaEycG55lD23w310zQiUWJdRg4rDBdWpsPSFbKvGg19vg== X-Received: by 2002:a37:a07:: with SMTP id 7mr3239736qkk.271.1599659075183; Wed, 09 Sep 2020 06:44:35 -0700 (PDT) Received: from raichu (toroon0560w-lp130-08-67-71-176-35.dsl.bell.ca. [67.71.176.35]) by smtp.gmail.com with ESMTPSA id r42sm3101200qtk.29.2020.09.09.06.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 06:44:34 -0700 (PDT) Sender: Mark Johnston Date: Wed, 9 Sep 2020 09:44:29 -0400 From: Mark Johnston To: Andriy Gapon Cc: Michal Meloun , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc] Message-ID: <20200909134429.GA65588@raichu> References: <202009080546.0885kAgk006783@repo.freebsd.org> <34826ee7-12a9-d309-1fee-cd2e95744603@FreeBSD.org> <67be7fa5-30dd-b7ee-1076-9c29195d83d3@gmail.com> <20200908124848.GB66031@raichu> <6b18b5ef-a743-3d5e-8dd2-24640614ec88@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b18b5ef-a743-3d5e-8dd2-24640614ec88@FreeBSD.org> X-Rspamd-Queue-Id: 4BmjtX2YkFz4HCc X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2020 13:44:36 -0000 On Wed, Sep 09, 2020 at 08:49:01AM +0300, Andriy Gapon wrote: > On 08/09/2020 15:48, Mark Johnston wrote: > > I observed the same thing recently as well: the compiler catches > > uninitialized variables only in simple cases. In my case, any uses of > > goto within the function seemed to silence the warning, even if they > > appeared after the uninitialized reference. > > I am running a kernel build now with this addition (for clang): > CWARNEXTRA+= -Wconditional-uninitialized -Wno-error-conditional-uninitialized > > It produces a ton of warnings. > Some of them are probably false positives, but some look quite reasonable. It has a lot of trouble with code patterns of the form: for (i = 0; i < 100; i++) { val = foo(); } if (val != 0) /* may be uninitialized!!1 */ bar(); or if (foo == bar) val = baz(); if (foo == bar && val == 3) The second example makes some sense to me since it's hard to prove that foo == bar will not change between the first and second evaluations. > E.g.: > sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized when > used here [-Wconditional-uninitialized] > TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); > > Indeed, there is a conditional 'goto failure' before a first assignment to p_drv > and the line is after the label. So, maybe the situation is impossible, but it > is reasonable to warn about it. > > But the number of false positives (and "possible but impossible" situations) is > too overwhelming. Yeah. I looked at maybe 30 warnings (out of hundreds) this morning and they were all false positives. KMSAN will provide a new tool for finding such bugs, but they will only be detected at runtime.