unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Andreas Schwab <schwab@suse.de>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] wcsmbs: Fix data race in __wcsmbs_clone_conv [BZ #24584]
Date: Mon, 20 May 2019 19:18:14 +0200	[thread overview]
Message-ID: <875zq5hwo9.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <mvmo93xjebq.fsf@suse.de> (Andreas Schwab's message of "Mon, 20 May 2019 18:11:37 +0200")

* Andreas Schwab:

> On Mai 20 2019, Florian Weimer <fweimer@redhat.com> wrote:
>
>> diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c
>> index 5494d0a23e..e33a9c1312 100644
>> --- a/wcsmbs/wcsmbsload.c
>> +++ b/wcsmbs/wcsmbsload.c
>> @@ -20,6 +20,7 @@
>>  #include <langinfo.h>
>>  #include <limits.h>
>>  #include <stdlib.h>
>> +#include <stdio.h>
>>  #include <string.h>
>>  
>>  #include <locale/localeinfo.h>
>> @@ -223,12 +224,24 @@ __wcsmbs_clone_conv (struct gconv_fcts *copy)
>>    /* Copy the data.  */
>>    *copy = *orig;
>>  
>> -  /* Now increment the usage counters.
>> -     Note: This assumes copy->*_nsteps == 1.  */
>> +  /* Now increment the usage counters.  Note: This assumes
>> +     copy->*_nsteps == 1.  The current locale holds a reference, so it
>> +     is still there after acquiring the lock.  */
>> +
>> +  __libc_lock_lock (__gconv_lock);
>> +
>> +  bool overflow = false;
>>    if (copy->towc->__shlib_handle != NULL)
>> -    ++copy->towc->__counter;
>> +    overflow |= __builtin_add_overflow (copy->towc->__counter, 1,
>> +					&copy->towc->__counter);
>>    if (copy->tomb->__shlib_handle != NULL)
>> -    ++copy->tomb->__counter;
>> +    overflow |= __builtin_add_overflow (copy->tomb->__counter, 1,
>> +					&copy->tomb->__counter);
>> +  if (overflow)
>> +    __libc_fatal ("\
>> +Fatal glibc error: gconv module reference counter overflow\n");
>> +
>> +  __libc_lock_unlock (__gconv_lock);
>
> Should the lock be dropped before __libc_fatal?

I think this is purely a matter of style because __libc_fatal does not
return.  Do you have a preference?

Thanks,
Florian

  reply	other threads:[~2019-05-20 17:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 11:40 [PATCH] wcsmbs: Fix data race in __wcsmbs_clone_conv [BZ #24584] Florian Weimer
2019-05-20 12:26 ` Andreas Schwab
2019-05-20 13:28   ` Florian Weimer
2019-05-20 16:11     ` Andreas Schwab
2019-05-20 17:18       ` Florian Weimer [this message]
2019-05-21  7:15         ` Andreas Schwab
2019-05-21  8:38           ` Florian Weimer
2019-05-21  9:04             ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zq5hwo9.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).