Bug #16820 [Fbk]: [PATCH] hangs in multithreaded environment (ZTS)

From: Date: Sun, 28 Dec 2014 19:51:08 +0000
Subject: Bug #16820 [Fbk]: [PATCH] hangs in multithreaded environment (ZTS)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189259@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=16820&edit=1

 ID:                 16820
 Updated by:         ab@php.net
 Reported by:        wmeler at wp-sa dot pl
 Summary:            [PATCH] hangs in multithreaded environment (ZTS)
 Status:             Feedback
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   * (ZTS only)
 PHP Version:        5.*, 6, 7, 8..
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

Kalle,

yeah, that's probably still an issue. Sadly TS builds are rarely utilized. The timed_out stuff
was used only on Windows. I however would need a reproduce scenario for the behaviour on Unix, but
that would actually be a comprehensive help, i guess.

Cheers, Anatol


Previous Comments:
------------------------------------------------------------------------
[2014-12-28 19:41:59] ab@php.net

@wmeler

Thanks for consequently staying on this issue. This is probably the best time to revisit this bug.
Please note that the windows part was just reworked (usage of timer queue) and is not in any of the
releases yet. Please check the latest branches starting with 5.5. Unfortunately your patch
can't apply to the current sources, for the unix part i can just say - yeah, that's
relevant as well. Even it'll slowdown the ZTS build, it'll stabilize it. It could be great
if you could check the unix branches. Furthermore, a reproduce scenario would value in gold, not
just a patch.

Thanks.

------------------------------------------------------------------------
[2014-12-28 19:04:40] kalle@php.net

Antal, is this still an issue in any recent version of PHP, or after the native-tls merge? If not
can you please close this report, or unassign it, thanks!

------------------------------------------------------------------------
[2009-09-09 19:52:35] jani@php.net

Dmitry, now there's patch to fix this.

------------------------------------------------------------------------
[2009-05-11 10:40:31] wmeler at wp-sa dot pl

Following patch solves the problem.

diff -urN php-5.3.0RC1/Zend/zend_config.h php-5.3.0RC1/Zend/zend_config.h
--- php-5.3.0RC1/Zend/zend_config.h	1970-01-01 01:00:00.000000000 +0100
+++ php-5.3.0RC1/Zend/zend_config.h	2009-05-11 11:40:05.408398000 +0200
@@ -0,0 +1,4 @@
+#include <../main/php_config.h>
+#if defined(APACHE) && defined(PHP_API_VERSION)
+#undef HAVE_DLFCN_H
+#endif
diff -urN php-5.3.0RC1/Zend/zend_execute_API.c php-5.3.0RC1/Zend/zend_execute_API.c
--- php-5.3.0RC1/Zend/zend_execute_API.c	2009-03-19 19:34:16.000000000 +0100
+++ php-5.3.0RC1/Zend/zend_execute_API.c	2009-05-11 11:01:28.663182000 +0200
@@ -185,7 +185,7 @@
 	zend_objects_store_init(&EG(objects_store), 1024);
 
 	EG(full_tables_cleanup) = 0;
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32) || defined(ZTS)
 	EG(timed_out) = 0;
 #endif
 
@@ -1280,6 +1280,15 @@
 }
 /* }}} */
 
+static void zend_timeout_signal_proc (int dummy) {
+	TSRMLS_FETCH();
+#ifdef ZTS
+	EG(timed_out) = 1;
+#else 
+	zend_timeout(0);
+#endif
+}
+
 #ifdef ZEND_WIN32
 static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/* {{{ */
 {
@@ -1424,7 +1433,7 @@
 			setitimer(ITIMER_REAL, &t_r, NULL);
 		}
 		if(reset_signals) {
-			signal(SIGALRM, zend_timeout);
+			signal(SIGALRM, zend_timeout_signal_proc`);
 			sigemptyset(&sigset);
 			sigaddset(&sigset, SIGALRM);
 		}
@@ -1432,7 +1441,7 @@
 			setitimer(ITIMER_PROF, &t_r, NULL);
 		}
 		if(reset_signals) {
-			signal(SIGPROF, zend_timeout);
+			signal(SIGPROF, zend_timeout_signal_proc);
 			sigemptyset(&sigset);
 			sigaddset(&sigset, SIGPROF);
 		}
diff -urN php-5.3.0RC1/Zend/zend_globals.h php-5.3.0RC1/Zend/zend_globals.h
--- php-5.3.0RC1/Zend/zend_globals.h	2009-03-18 11:18:09.000000000 +0100
+++ php-5.3.0RC1/Zend/zend_globals.h	2009-05-11 10:50:10.810172000 +0200
@@ -213,8 +213,10 @@
 	/* for extended information support */
 	zend_bool no_extensions;
 
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32)||defined(ZTS)
 	zend_bool timed_out;
+#endif
+#ifdef ZEND_WIN32
 	OSVERSIONINFOEX windows_version_info;
 #endif
 
diff -urN php-5.3.0RC1/Zend/zend_vm_execute.h php-5.3.0RC1/Zend/zend_vm_execute.h
--- php-5.3.0RC1/Zend/zend_vm_execute.h	2009-03-18 19:49:27.000000000 +0100
+++ php-5.3.0RC1/Zend/zend_vm_execute.h	2009-05-11 10:48:32.487352000 +0200
@@ -95,7 +95,7 @@
 	
 	while (1) {
     	int ret;
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32) || defined(ZTS)
 		if (EG(timed_out)) {
 			zend_timeout(0);
 		}
diff -urN php-5.3.0RC1/Zend/zend_vm_execute.skl php-5.3.0RC1/Zend/zend_vm_execute.skl
--- php-5.3.0RC1/Zend/zend_vm_execute.skl	2008-06-11 15:18:41.000000000 +0200
+++ php-5.3.0RC1/Zend/zend_vm_execute.skl	2009-05-11 10:48:59.796813000 +0200
@@ -61,7 +61,7 @@
 	
 	while (1) {
     {%ZEND_VM_CONTINUE_LABEL%}
-#ifdef ZEND_WIN32
+#if defined(ZEND_WIN32) || defined(ZTS)
 		if (EG(timed_out)) {
 			zend_timeout(0);
 		}

------------------------------------------------------------------------
[2009-03-11 09:14:58] wmeler at wp-sa dot pl

What should I say to make you stop using longjmp family calls in signal handler? 

IT IS NOT THREAD SAFE !!!

You probably can reproduce it with:

./configure --enable-maintainer-zts; make; sapi/cli/php ../aaa.php

Fatal error: Maximum execution time of 1 second exceeded in /root/aaa.php on line 7
6504146zend_mm_heap corrupted

aaa.php is a script posted 21 Jul 2003 2:07am UTC.

------------------------------------------------------------------------


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=16820


--
Edit this bug report at https://bugs.php.net/bug.php?id=16820&edit=1


Thread (39 messages)

« previous php.bugs (#189259) next »