From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 64AC93858C30 for ; Mon, 12 Feb 2024 15:28:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64AC93858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 64AC93858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707751710; cv=none; b=v7+6Ta/WnHnPyanBQmH+jsr/u1CEvn168ad6GSVe2C6v3P1Fd7RgP6HFs2iBvfLQHpvMbbvrOep41OPvCihOrg2ogvaSwZUfnYvt2x/tmdKSGj2rSVxTsdAS8jU/iq08VP2mvIlyGvuIMvdqRz4bnaQ//9Yw6JoVShhPr4FTbZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707751710; c=relaxed/simple; bh=kIVAqKDoKEOPosBSWL/OSTH7DqHQ7l6A/9UIOrRO9Rw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=M8r16HLc2TomlAFALRZfIaBhc6wnwVVA3ETPoYicVEhmRcmgjRZvQKc1ujBP5EhSLOUAvR9TFfWzLqWNyYR+QWqLaH5SHVvrDfBJ7yDUsvEdyDZEf9iperIOd7GcyFKMEvk9SvtpT3Y5HpZ12WvTRQWBwLNzvW3Ij7GWnzECxjM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707751707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9TJhHeGJXY3HCl4yXpoZUPEgfqhw/7h288uc7TvWjkk=; b=XKnwHR8oKrn3ohIgXk+CBsoy4JqbJb4+NbNJSHo9FAzNSFsBxZnDIhn9ttveC7n577jYm3 tdsDGaqsXM5nEC6tvCkYmsCEbHAFw4kCFGe+zFVNZry64g7V0DMrt8m0+bdfd4zE77xpvn DFA3OAyTr4esZGfyHcj5/TlMHEzysAM= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-LaduAlYLOlmqvaorE7MphQ-1; Mon, 12 Feb 2024 10:28:25 -0500 X-MC-Unique: LaduAlYLOlmqvaorE7MphQ-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3bfeb75d667so3518941b6e.0 for ; Mon, 12 Feb 2024 07:28:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707751703; x=1708356503; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9TJhHeGJXY3HCl4yXpoZUPEgfqhw/7h288uc7TvWjkk=; b=Tm0WLhvV+rf0m09etTVRU98jcF3BWXKT9ZRUImt2Fvxh/iBXe6+doqjeLodxtld0Ky RmEfwcCxz5QG9KdXS9KwcGDpTjox5YkGeJwsH6YBqVmozlS4h/1mE18vyTPbLWUFZ2zc 1COwAVMtLpXlUyxn6aelLOAAaYqybEQtpNIkDy13BsLZD6h4V5rl5KRL+TbqEenWcMvy ML1HJCnXtT3re021NaKZ36+5Oewt19Ae066FWlxlstBTRqKsaHvO3p9uSwaT8AiadTvM 2iF0LRPzQNf/INsjCU7pnWidSpy6MVedzeeb0CuklSxVHf7XK3/0c+iC/r18hUPsa4Mm TFJw== X-Forwarded-Encrypted: i=1; AJvYcCW65qe/cx+ZRvGBPssG/edHHHPo00oycHa5zVO4O6Y5yhwqn5EuyxmLxkzK//pI75KGcjmaHGZ4otVWsp4ND2QBuFLOMpq61A== X-Gm-Message-State: AOJu0Yw2Pb70EM3Rz++EN9jf6Hy+sz99pmdvLyGzdTF218lhyJwHfnb0 mM0stsW+2XrkzU67Ftu76U1bSyaLX8dw0nGLM5V5hSjkIDrSxkORYaoadbnDaLUbeMhZY5ma924 cv/tz5DIlPNsd5n9ZMXQ0pOpfnPi09prAAbmZusAAEz8VnqHUH6oOCaFESDyB1OA= X-Received: by 2002:a05:6358:70c:b0:17a:df3a:c2af with SMTP id e12-20020a056358070c00b0017adf3ac2afmr4587996rwj.26.1707751703225; Mon, 12 Feb 2024 07:28:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IETQuTM2nxwwLGMQHAwDhQcnFOXIgSXkJYc50/wZ3ZLtdx2U+IhVxpYvz5TIOxAHWhzK7LOBw== X-Received: by 2002:a05:6358:70c:b0:17a:df3a:c2af with SMTP id e12-20020a056358070c00b0017adf3ac2afmr4587989rwj.26.1707751702907; Mon, 12 Feb 2024 07:28:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXqwofza9pkCRTlUjGKY0+lJ5Cm+CFTCRvAszYe9d0geIM0IOST2/PUB+qEQSFxkWMRsrWmXVOe/TSsPjPjeLhkgtCFnoU2EA== Received: from [192.168.1.5] ([79.123.79.31]) by smtp.gmail.com with ESMTPSA id pi16-20020a0562144a9000b0068cb4cba33esm247570qvb.87.2024.02.12.07.28.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 07:28:22 -0800 (PST) Message-ID: Date: Mon, 12 Feb 2024 15:28:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] Make several more BFD globals thread-local To: Tom Tromey , binutils@sourceware.org References: <20240130010540.1754740-1-tom@tromey.com> <20240130010540.1754740-2-tom@tromey.com> From: Nick Clifton Autocrypt: addr=nickc@redhat.com; keydata= xsFNBFm/2cUBEADkvRqMWfAryJ52T4J/640Av5cam9ojdFih9MjcX7QWFxIzJfTFYq2z+nb4 omdfZosdCJL2zGcn6C0AxpHNvxR9HMDkEyFHKrjDh4xWU+pH4z9azQEqJh331X7UzbZldqQo 16VkuVavgsTJaHcXm+nGIBTcUbl2oiTtHhmuaYxx6JTMcFjC7vyO5mLBw78wt52HBYweJ0Nj HBvvH/JxbAAULSPRUC61K0exlO49VFbFETQNG1hZTKEji95fPbre7PpXQ0ewQShUgttEE/J3 UA4jYaF9lOcZgUzbA27xTV//KomP0D30yr4e4EJEJYYNKa3hofTEHDXeeNgM25tprhBUMdbV RZpf2Keuk2uDVwc+EiOVri48rb1NU+60sOXvoGO6Ks81+mhAGmrBrlgLhAp8K1HPHI4MG4gH nrMqX2rEGUGRPFjC3qqVVlPm8H05PnosNqDLQ1Pf7C0pVgsCx6hKQB7Y1qBui7aoj9zeFaQg pYef+CEERIKEcWwrjaOJwK3pi9HFdxS0NNWYZj8HPzz/AsgTTQdsbulPlVq2SsctmOnL42CZ OCTppGYwl53CG/EqVY+UQBzFzJBaY8TJRFFYVEy5/HH4H11rMoZwqIkk71EOGU3X6mWlANRi kR3M4GhVITRzuaV69Fed+OeXcCmP94ASLfuhBR2uynmcHpBKpwARAQABzTtOaWNrIENsaWZ0 b24gKENoaWVmIEJpbnV0aWxzIE1haW50YWluZXIpIDxuaWNrY0ByZWRoYXQuY29tPsLBeAQT AQIAIgUCWb/ZxQIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQE/zvid2ePE9cOxAA 3cX1bdDaTFttTqukdPXLCtD2aNwJos4vB4LYPSgugLkYaHIQH9d1NQPhS0TlUeovnFNESLaV soihv0YmBUCyL4jE52FRoTjE6fUhYkFNqIWN2HYwkVrSap2UUJFquRVoVbPkbSup8P+D8eyd BbdxsY6f+5E8Rtz5ibV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0giMgjhCQtuc99E4nQE9KZ44DKsnqRabK9s3zYE3PIkCFIEZcUiJXSXWWOIdJ43 j+YyFHU5hqXfECM6rzKGBeBUGTzyWcOX6YwRM4LzQDVJwYG8cVfth+v4/ImcXR43D4WVxxBE AjKag02b+1yfABEBAAHCwV8EGAECAAkFAlm/2cUCGwwACgkQE/zvid2ePE/dqQ/6ApUwgsZz tps0MOdRddjPwz44pWXS5MG45irMQXELGQyxkrafc8lwHeABYstoK8dpopTcJGE3dZGL3JNz 1YWxQ5AV4uyqBn5N8RubcA8NzR6DQP+OGPIwzMketvVC/cbbKDZqf0uTDy3jP65OFhSkTEIy nYv1Mb4JJl3Sq+haUbfWLAV5nboSuHmiZE6Bz2+TjdoVkNwHBfpqxu6MlWka+P98SUcmY8iV hPy9QC1XFOGdFDFf1kYgHW27mFwds35NQhNARgftAVz9FZXruW6tFIIfisjr3rVjD9R8VgL7 l5vMr9ylOFpepnI6+wd2X1566HW7F1Zw1DIrY2NHL7kL5635bHrJY4n7o/n7Elk/Ca/MAqzd IZxz6orfXeImsqZ6ODn4Y47PToS3Tr3bMNN9N6tmOPQZkJGHDBExbhAi/Jp8fpWxMmpVCUl6 c85cOBCR4s8tZsvGYOjR3CvqKrX4bb8GElrhOvAJa6DdmZXc7AyoVMaTvhpq3gJYKmC64oqt 7zwIHwaCxTbP6C6oUp9ENRV7nHnXN3BlvIgCo4QEs6HkDzkmgYlCEOKBiDyVMSkPDZdsspa+ K4GlU2Swi/BDJMjtDxyo+K0M81LXXxOeRfEIfPtZ3ddxBKPva1uSsuz+pbN9d1JY8Ko5T/h1 6susi2ReUyNJEJaSnjO5z13TQ1U= In-Reply-To: <20240130010540.1754740-2-tom@tromey.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Tom, > Among other things, PR gdb/31264 points out a race in bfd_check_format > -- it sets the error handler, which is a global. > > Looking into this a bit more, I found several other possible races: > the "in_check_format" static local variable in > bfd_check_format_matches, and the contents of per_xvec_warn. > > This patch makes all of these thread-local. > > I don't actually think this is the best way to approach this. > "in_check_format" and the per-xvec warnings could be done by setting a > flag on the BFD, avoiding globals entirely. I can do that if you > want; I just wasn't sure if that is desirable or not. Actually, I think that I would prefer this alternative solution. I am particularly worried about making the error handler thread local when this might not match the expectations of a client using the BFD library. Since the error handler is currently global, a client can expect to set it once and have it affect all threads. Looking at the code in bfd_check_format_matches() it seems clear that the error handler manipulation is really a hack, based upon the single threaded nature of the BFD library. This become problematical when the BFD library is used in a multi-threaded environment. It seems to me that the proper thing to do would be to [throw away the BFD library and use something designed from the ground up to thread-safe], ahem, I mean provide a thread safe way for bfd_check_format_matches to override the error handler within its local context, without it affecting the global error handler for other threads *and* still allowing the client to call bfd_set_error_handler to change the error handler for all threads at once. This sounds like a lot of work however, and probably something that ought to be done as part of a larger project to turn the BFD library into a thread-safe and multi-threaded library. What are you thoughts ? Cheers Nick