From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id B4C2C3858D1E for ; Wed, 2 Aug 2023 19:29:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4C2C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-78625caa702so5859439f.1 for ; Wed, 02 Aug 2023 12:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1691004574; x=1691609374; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=dtgZUwfOLHIfsEhtR4WkCkSzcUOOZ56VTigr3JDV8kk=; b=IJ1ssyGVuhpPnCwWiqp7ULcSmh+XI/KwjAU1AMgSf/Skt5jO4LMGOdNwBEL3P3oeul Qo/Ei7jtpYmgpEyND0w4KNynxCNBVdW7NFHOum4LrtGCRbp1snh4rGxnB5gD9Hn56vBq ow0zH+zKU2zb02Rt4yA5gxexoawSNJ6vKBH/LEwMImx6PUBSsKVgV7YaLcE476ktWrWJ Ty94TIo/RLE2nbEnTFGh77BFn5pLMII92Hs5u1JCAzIaP8AnO+kxaH+61BzdzSbGtrvi 34fGAWv4d7M0aQEf3Y9BTYjP0V1kusnbhwUYHan/sD/8iJsjWCE86+P5N5V7Db42Par6 e37w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691004574; x=1691609374; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dtgZUwfOLHIfsEhtR4WkCkSzcUOOZ56VTigr3JDV8kk=; b=P6RM+K1pSbITQXPVl1AcjNRiUEgKS+6fnxYRCmDxC1/lGsVA/AUbtBwS+nPrueITOq EpsOgzQ0ogJQlduKPXSZHGgAIZLktntAXU5rt/NailcxU90Im1pP2lzpA4HHS7XyOFeu qvqG0LQupcIGV2x+DeumWq5HBgeGpcYcJ/dtUc5gVefAzHD3QdyErErdmP/kuos7Itiq ozkXEPJbjDbQmS7a6H19BYgMNu4ZJSC5wyzx378EYGx1vmsZ1aH/EBABg7bjguVOwLw2 dgy3VizeskVdd0JxzGnnNgh7jXhePG08d+SGYHmo1c0b8+IZVAsRSwNLH+EwyJ3UV35w qJVA== X-Gm-Message-State: ABy/qLbRDqKa1CaheMHUX4yT9+GMl1QqJoc5dnWcorVHzYKFpNrgX9zr VWN/MmEFl0HQ52klz2INOZL+sw== X-Google-Smtp-Source: APBJJlFCYZuWhql1dvVdVM1X+3At+mkt2pQF+jvPfd28rb0fVQGEJmMxEwTClEU6mnBrFnFl2NyJhg== X-Received: by 2002:a6b:5901:0:b0:760:e308:107e with SMTP id n1-20020a6b5901000000b00760e308107emr13762909iob.0.1691004574726; Wed, 02 Aug 2023 12:29:34 -0700 (PDT) Received: from murgatroyd (75-166-148-59.hlrn.qwest.net. [75.166.148.59]) by smtp.gmail.com with ESMTPSA id a10-20020a056638018a00b0041f552e4aa2sm4509594jaq.135.2023.08.02.12.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 12:29:34 -0700 (PDT) From: Tom Tromey To: Tom de Vries via Gdb-patches Cc: Tom de Vries Subject: Re: [PATCH v2 1/6] [gdb/symtab] Fix data race on index_cache::m_enabled References: <20230802095305.3668-1-tdevries@suse.de> <20230802095305.3668-2-tdevries@suse.de> X-Attribution: Tom Date: Wed, 02 Aug 2023 13:29:33 -0600 In-Reply-To: <20230802095305.3668-2-tdevries@suse.de> (Tom de Vries via Gdb-patches's message of "Wed, 2 Aug 2023 11:53:00 +0200") Message-ID: <87v8dxdyzm.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: >>>>> "Tom" == Tom de Vries via Gdb-patches writes: Tom> With gdb build with -fsanitize=thread and test-case gdb.base/index-cache.exp I Tom> run into: [race] Tom> Fix this by capturing the value of index_cache::m_enabled in the main thread, Tom> and using the captured value in the worker thread. Thanks for the patch. I have some stylistic nits but otherwise it seems fine to me. Tom> + struct index_cache_store_context ctx (global_index_cache); I think we tend to avoid the struct/class keyword in cases like this now. Tom> + const struct index_cache_store_context &ctx) ... basically everywhere. Tom> +index_cache_store_context::index_cache_store_context (const index_cache &ic) Tom> +{ Tom> + m_enabled = ic.enabled (); It's better to use the initializer syntax like : m_enabled (ic.enabled ()) This can be in the header if possible (I didn't try). Tom> +struct index_cache_store_context Tom> +{ Tom> + friend class index_cache; Tom> + Tom> + index_cache_store_context(const index_cache &ic); Single-argument constructors should be 'explicit' as a rule. Tom