RE: [PHP-CVS] com php-src: fix thread safety: Zend/zend_strtod.c
| From: | ab@php.net | Date: | Wed, 29 Jul 2015 16:43:55 +0000 |
| Subject: | RE: [PHP-CVS] com php-src: fix thread safety: Zend/zend_strtod.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-88233@lists.php.net to get a copy of this message | ||
Hi Nikita,
> -----Original Message-----
> From: Nikita Popov [mailto:nikita.ppv@gmail.com]
> Sent: Wednesday, July 29, 2015 5:59 PM
> To: Anatol Belski <ab@php.net>
> Cc: php-cvs@lists.php.net
> Subject: Re: [PHP-CVS] com php-src: fix thread safety: Zend/zend_strtod.c
>
> On Wed, Jul 29, 2015 at 5:26 PM, Anatol Belski <ab@php.net> wrote:
>
> > Commit: c17289e59c41368538f75b25d49b5604d968b616
> > Author: Anatol Belski <ab@php.net> Wed, 29 Jul 2015 15:12:45
> > +0200
> > Parents: db70a337ff79be773b82e00a7483f69727af25aa
> > Branches: master
> >
> > Link:
> >
> > http://git.php.net/?p=php-src.git;a=commitdiff;h=c17289e59c41368538f75
> > b25d49b5604d968b616
> >
> > Log:
> > fix thread safety
> >
> > Changed paths:
> > M Zend/zend_strtod.c
> >
> >
> > Diff:
> > diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index
> > 4fa9ee3..0bdb8c0 100644
> > --- a/Zend/zend_strtod.c
> > +++ b/Zend/zend_strtod.c
> > @@ -3601,7 +3601,7 @@ zend_strtod
> > }
> >
> > #ifndef MULTIPLE_THREADS
> > - static char *dtoa_result;
> > + ZEND_TLS char *dtoa_result;
> > #endif
> >
> > static char *
> >
>
> This is behind a MULTIPLE_THREADS guard, which we enable for ZTS. So
> probably not necessary to declare it as TLS?
>
Yeah, MULTIPLE_THREADS is only activated on ZTS. But I was checking through the code and how it
looks like there is no locking (ACQUIRE_DTOA_LOCK ) around the operations on that variable. It being
only static isn't thread safe, while of course better than being just global. Or you mean it
were thread safe in the core usage? Actually haven't seen that as well, fe zend_dtoa usage in
snprintf.c
Regards
Anatol