Bug #71596 [Fbk->Csd]: Segmentation fault on ZTS with date function (setlocale)

From: Date: Thu, 18 Feb 2016 18:19:58 +0000
Subject: Bug #71596 [Fbk->Csd]: Segmentation fault on ZTS with date function (setlocale)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199324@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71596&edit=1 ID: 71596 Updated by: ab@php.net Reported by: maroszek at gmx dot net Summary: Segmentation fault on ZTS with date function (setlocale) -Status: Feedback +Status: Closed Type: Bug Package: Date/time related Operating System: Windows PHP Version: 7.0.3 -Assigned To: +Assigned To: ab Block user comment: N Private report: N New Comment: Applied in 632fc51d98494565a71ae97a81bd7d440dbb116a. Thanks. Previous Comments: ------------------------------------------------------------------------ [2016-02-17 14:05:03] ab@php.net Thanks very much for the follow up. I'll apply this one to 5.6 then. Bug #71129 is certainly an issue as well, but an unrelated one. Probably it's good so, fixing them step by step and testing good. Thanks! ------------------------------------------------------------------------ [2016-02-17 10:15:04] maroszek at gmx dot net Thanks! That works flawlessly. Tested and works for 5.6.18 aswell, if you want to backport the patch. Regarding the other issue: I was not able to reproduce the crash using a debug build. I saw it once in the release version... but had no good backtrace. If it happens again with a good backtrace i will post it. Regarding my statement that the backtrace changed: I think it was only looking a bit different, but was also due to the setlocale bug. It never had to do anything with the shutdown crash. ------------------------------------------------------------------------ [2016-02-16 19:15:31] ab@php.net Oh yes, thanks. I was just using the code you posted directly into the thread :) so had nearly the same date() call. I was finally able to reproduce crashes in setlocale, seems it was only passing by luck previously. I was reading through the docs again, there is another page where the docs are more clear https://msdn.microsoft.com/en-us/library/ms235302.aspx . Looks like what you told in the description is right. This is contradicting another doc page and the code snippet there a bit, telling that the _configthreadlocale has to be called in every thread. If you apply this patch, rebuild PHP and the test program, do you see any setlocale crashes? diff --git a/main/SAPI.c b/main/SAPI.c index 9781f18..4084f7e 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -437,6 +437,9 @@ SAPI_API void sapi_activate_headers_only(void) SAPI_API void sapi_activate(void) { +#if defined(PHP_WIN32) && defined(ZTS) + _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); +#endif zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0); SG(sapi_headers).send_default_content_type = 1; With this in, the crash i've posted previously remains. But the setlocale one disappears. You've mentioned previously that adding _configthreadlocale call to every thread changes your backtrace. How does it look like? Thanks. ------------------------------------------------------------------------ [2016-02-16 15:22:46] maroszek at gmx dot net In my first comment i have attached a full project, if that helps. Contents of date.php: <? //ini_set( 'date.timezone', 'Europe/Berlin' ); //date_default_timezone_set( 'Europe/Berlin' ); date("Ymd"); ------------------------------------------------------------------------ [2016-02-16 15:15:29] ab@php.net I used your latest variant and have some crash, too. But it's not about set locale > php7ts.dll!zend_hash_graceful_reverse_destroy(_zend_array * ht=0x0000020f71c909a0) Line 1489 C php7ts.dll!shutdown_executor() Line 278 C php7ts.dll!zend_deactivate() Line 969 C php7ts.dll!php_request_shutdown(void * dummy=0x0000000000000000) Line 1826 C bug71596.exe!phpThread(void * params=0x0000000000000000) Line 130 C++ bug71596.exe!thread_start<unsigned int (__cdecl*)(void * __ptr64)>(void * const parameter=0x00007ff621d579c4) Line 115 C++ It's incomplete yet, have to recompile a debug build to get more info on that. It currently shows a crash while destroying the symbol table on some RSHUTDOWN. This might or might not be related to your locale crash. Btw, what is the content of your date.php, i was just putting some date("i"); in there from what i saw in your bt. Thanks. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=71596 -- Edit this bug report at https://bugs.php.net/bug.php?id=71596&edit=1

« previous php.bugs (#199324) next »