develooper Front page | perl.perl5.porters | Postings from March 2018

Re: New 'PL_lc_numeric_mutex' warnings when building with clang

Thread Previous | Thread Next
From:
James E Keenan
Date:
March 2, 2018 13:46
Subject:
Re: New 'PL_lc_numeric_mutex' warnings when building with clang
Message ID:
7fda4974-b8e6-6733-0fdf-82ac494e4c4e@pobox.com
On 02/25/2018 11:47 PM, Karl Williamson wrote:
> On 02/25/2018 07:48 PM, James E Keenan wrote:
>> On 02/25/2018 08:24 PM, Karl Williamson wrote:
>>> On 02/25/2018 06:13 PM, James E Keenan wrote:
>>>> On 02/25/2018 12:13 PM, Karl Williamson wrote:
>>>>> On 02/25/2018 08:12 AM, James E Keenan wrote:
>>>>>> When building perl as I typically do on FreeBSD-11.0 (clang, 
>>>>>> threaded), I have begun to experience a large number of 'make' 
>>>>>> warnings not previously seen.  Gzipped build log attached, but 
>>>>>> here is a taste:
>>>>>
>>>>> I had seen these and researched them, but in order to meet the 
>>>>> deadline, I committed anyway, as they are harmless.  I'm sorry that 
>>>>> I didn't communicate this issue, so that you spent time on it.  We 
>>>>> need to find a way to silence these warnings, and I presume that 
>>>>> there is. I looked them up, and in some documentation about it 
>>>>> somewhere, it admits that this is bogus; that their analysis 
>>>>> routine that's generating these doesn't get this situation right.
>>>>>
>>>>>>
>>>>>> #####
>>>>>> dump.c:497:9: warning: mutex 'PL_lc_numeric_mutex' is not held on 
>>>>>> every path through here [-Wthread-safety-analysis]
>>>>>>          STORE_LC_NUMERIC_SET_STANDARD();
>>>>>>          ^
>>>>>> ./perl.h:5950:13: note: expanded from macro 
>>>>>> 'STORE_LC_NUMERIC_SET_STANDARD'
>>>>>>              LC_NUMERIC_LOCK(_NOT_IN_NUMERIC_STANDARD);     \
>>>>>>              ^
>>>>>> ./perl.h:5593:9: note: expanded from macro 'LC_NUMERIC_LOCK'
>>>>>>          STMT_START {     \
>>>>>>          ^
>>>>>> ./perl.h:530:29: note: expanded from macro 'STMT_START'
>>>>>> #   define STMT_START   (void)( /* gcc supports "({ STATEMENTS; 
>>>>>> })" */
>>>>>>                                ^
>>>>>> dump.c:497:9: note: mutex acquired here
>>>>>> ./perl.h:5950:13: note: expanded from macro 
>>>>>> 'STORE_LC_NUMERIC_SET_STANDARD'
>>>>>>              LC_NUMERIC_LOCK(_NOT_IN_NUMERIC_STANDARD);     \
>>>>>>              ^
>>>>>> ./perl.h:5595:17: note: expanded from macro 'LC_NUMERIC_LOCK'
>>>>>>                  MUTEX_LOCK(&PL_lc_numeric_mutex);     \
>>>>>>                  ^
>>>>>> ./thread.h:216:14: note: expanded from macro 'MUTEX_LOCK'
>>>>>>          if ((_eC_ = 
>>>>>> perl_pthread_mutex_lock((m))))                      \
>>>>>>                      ^
>>>>>> ./thread.h:206:40: note: expanded from macro 
>>>>>> 'perl_pthread_mutex_lock'
>>>>>> #    define perl_pthread_mutex_lock(m) perl_tsa_mutex_lock(m)
>>>>>>                                         ^
>>>>>> dump.c:499:9: warning: releasing mutex 'PL_lc_numeric_mutex' that 
>>>>>> was not held [-Wthread-safety-analysis]
>>>>>>          RESTORE_LC_NUMERIC();
>>>>>>          ^
>>>>>> ./perl.h:5923:13: note: expanded from macro 'RESTORE_LC_NUMERIC'
>>>>>>              LC_NUMERIC_UNLOCK;     \
>>>>>>              ^
>>>>>> ./perl.h:5617:17: note: expanded from macro 'LC_NUMERIC_UNLOCK'
>>>>>>                  MUTEX_UNLOCK(&PL_lc_numeric_mutex);     \
>>>>>>                  ^
>>>>>> ./thread.h:224:14: note: expanded from macro 'MUTEX_UNLOCK'
>>>>>>          if ((_eC_ = 
>>>>>> perl_pthread_mutex_unlock((m))))                    \
>>>>>>                      ^
>>>>>> ./thread.h:207:42: note: expanded from macro 
>>>>>> 'perl_pthread_mutex_unlock'
>>>>>> #    define perl_pthread_mutex_unlock(m) perl_tsa_mutex_unlock(m)
>>>>>>                                           ^
>>>>>> #####
>>>>>>
>>>>>> The first smoke test where I logged these warnings was at this 
>>>>>> commit:
>>>>>>
>>>>>> #####
>>>>>> $ gitshowf 2a05854a1ad5472d00de22f8fcc284cdc8fd1503
>>>>>> commit 2a05854a1ad5472d00de22f8fcc284cdc8fd1503
>>>>>> Merge: 6de18f4 957ac25
>>>>>> Author:     Father Chrysostomos <sprout@cpan.org>
>>>>>> AuthorDate: Sun Feb 18 16:41:09 2018 -0800
>>>>>> Commit:     Father Chrysostomos <sprout@cpan.org>
>>>>>> CommitDate: Sun Feb 18 16:41:09 2018 -0800
>>>>>>
>>>>>>      [Merge] ‘Nonelem’ scalars
>>>>>>
>>>>>> #####
>>>>>>
>>>>>> However, based on 'git blame perl.h', I suspect that the warnings 
>>>>>> were first introduced here:
>>>>>>
>>>>>> #####
>>>>>> commit 49d7d366441813aa7301b1a437e302372f04f31a
>>>>>> Author:     Karl Williamson <khw@cpan.org>
>>>>>> AuthorDate: Tue Feb 13 13:12:50 2018 -0700
>>>>>> Commit:     Karl Williamson <khw@cpan.org>
>>>>>> CommitDate: Sun Feb 18 15:44:23 2018 -0700
>>>>>>
>>>>>>      Latch LC_NUMERIC during critical sections
>>>>>> #####
>>>>>>
>>>>>> Karl, can you take a look?
>>>>>>
>>>>>> Thank you very much.
>>>>>> Jim Keenan
>>>>
>>>> One thing I find curious/annoying is that I do not get these 
>>>> warnings when I build with clang (and threaded) on Linux or 
>>>> FreeBSD-10.3 -- only on FreeBSD-11.0.
>>>>
>>>> Carlos Guevara:  Are you getting warnings like these in your 
>>>> FreeBSD-12 smokers?
>>>>
>>>> Thank you very much.
>>>> Jim Keenan
>>>>
>>>
>>> I believe this is a relatively new clang feature.
>>>
>>> These mutexes are not needed unless there is a race condition with 
>>> changing locales.  Therefore they aren't used and there will not be 
>>> warnings on unthreaded builds, or on builds using thread-safe locale 
>>> operations.  Linux has thread-safe builds.  Is the 10.3 clang the 
>>> same as 11.0. 
>>
>> fbsd 10.3: clang 3.4.1
>> fbsd 11.0: clang 3.8.0
>>
>>   Carlos won't get them on 12, because it is thread-safe.
>>
>>
> 
> I remember now, the documentation indicated a way to turn off the 
> warnings.  So I have now tried it in smoke-me/khw-locale.
> 
> Please see if this fixes the problem for you.

commits b2f82b52000c3bfe6e6df200c775e2a639d91552 and 
ffceb0b88fd1be4a700ff14e5c9b6bd2bfe02802 have resolved the problem.

Compare these two smoke reports from FreeBSD-11.0:

http://perl5.test-smoke.org/report/63247
v5.27.8-416-g1c8104f6f4
2018-03-01 01:31:51+00
# lots of warnings

http://perl5.test-smoke.org/report/63287
v5.27.8-419-gb2f82b5200
2018-03-02 02:11:28+00
# warnings-free

Thanks for your investigation.
Jim Keenan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About