From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66884 invoked by alias); 6 Mar 2020 08:04:21 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 66865 invoked by uid 89); 6 Mar 2020 08:04:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: albireo.enyo.de Received: from albireo.enyo.de (HELO albireo.enyo.de) (37.24.231.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 08:04:15 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1jA7xp-0008QF-MU; Fri, 06 Mar 2020 08:04:09 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1jA7wE-0004Ke-GJ; Fri, 06 Mar 2020 09:02:30 +0100 From: Florian Weimer To: David Malcolm Cc: Andrea Corallo , "gcc-patches\@gcc.gnu.org" , "jit\@gcc.gnu.org" , nd Subject: Re: [PATCH][gcc] libgccjit: introduce version entry points References: Date: Wed, 01 Jan 2020 00:00:00 -0000 In-Reply-To: (David Malcolm's message of "Thu, 05 Mar 2020 21:34:53 -0500") Message-ID: <87v9nh3o89.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2020-q1/txt/msg00009.txt * David Malcolm: > > My first thought here was that we should have a way to get all three at > once, but it turns out that parse_basever does its own caching > internally. > > I don't think the current implementation is thread-safe; parse_basever > has: > > static int s_major = -1, s_minor, s_patchlevel; > > if (s_major == -1) > if (sscanf (BASEVER, "%d.%d.%d", &s_major, &s_minor, &s_patchlevel) != 3) > { > sscanf (BASEVER, "%d.%d", &s_major, &s_minor); > s_patchlevel = 0; > } > > I think there's a race here: Right, it's not thread-safe. One possiblity would be to store all three numbers in one unsigned int, and used relaxed MO loads and stores. A zero value would indicate that initialization is needed. It will break if there are ever more than 1000 or so GCC releases, but it will be good for a while.