Professional Web Applications Themes

[PHP-DEV] PHP thread stack problem on HPUX - PHP Development

A few months back i submitted a bug report #21855 and forgotten about it. In short ...certain complex enough scripts would cause PHP to crash and burn on HPUX. The gdb backtraces and the fault generated seemed to indicate that memory access was beging performed in the guard pages located just beyond stack limits. The bug has been fixed in our HP Apache distribution for sometime now. The Problem: HPUX has a default thread stack limit pitched at 64k on PARISC and 256k on Itanium. For sufficiently complex scripts, I measured and found that PHP's execution engine (execute() in zend_engine.c ...

  1. #1

    Default [PHP-DEV] PHP thread stack problem on HPUX

    A few months back i submitted a bug report #21855 and forgotten about it.

    In short ...certain complex enough scripts would cause PHP to crash and burn
    on HPUX. The gdb backtraces and the fault generated seemed to indicate that
    memory access was beging performed in the guard pages located just beyond
    stack limits.

    The bug has been fixed in our HP Apache distribution for sometime now.

    The Problem:
    HPUX has a default thread stack limit pitched at 64k on PARISC and 256k on
    Itanium. For sufficiently complex scripts, I measured and found that PHP's
    execution engine (execute() in zend_engine.c ) gets recursive and consumes
    more than this default stack limit. The reason being that dynamic memory
    allocation (for the opcodes?)is done on the stack instead of heap (for
    performance reasons I guess).

    This has showed up on HPUX easily perhaps due to its relatively smaller
    default stack size. But in any case one cant count on PHP to be under the
    stack limit
    for "sufficiently complex" scripts on any OS as such which i beleive is
    typically is KiloBytes. Increasing thread stack size at thread creation time
    only (in apache)
    delays the onset of problem and wastes memory for Apache threads that are
    not
    servicing PHP requests.

    Solution:
    Allocate from the heap, and take the performance hit.


    ********************************
    <<< file 1: zend_execute.c
    >>> file 2: fixed_zend_execute.c
    ********************************
    -----[1015 changed to 1015]-----
    < EX(Ts) = (temp_variable *)
    do_alloca(sizeof(temp_variable)*op_array->T);
    ---
    > EX(Ts) = (temp_variable *)
    emalloc(sizeof(temp_variable)*op_array->T);
    -----[1711 changed to 1711]-----
    < free_alloca(EX(Ts));
    ---
    > efree(EX(Ts));
    --Roshan

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    NAIK,ROSHAN Guest

  2. #2

    Default Re: [PHP-DEV] PHP thread stack problem on HPUX

    Possibly better one (not tested):

    Index: Zend/zend.h
    ================================================== =================
    RCS file: /repository/ZendEngine2/zend.h,v
    retrieving revision 1.210
    diff -u -r1.210 zend.h
    --- Zend/zend.h 10 Jun 2003 20:03:24 -0000 1.210
    +++ Zend/zend.h 19 Jul 2003 03:54:19 -0000
    -146,7 +146,7
    # endif
    #endif

    -#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE))
    +#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !defined(HPUX)
    # define do_alloca(p) alloca(p)
    # define free_alloca(p)
    #else

    Moriyoshi


    "NAIK,ROSHAN (HP-Cupertino,ex1)" <roshan.naikhp.com> wrote:
    >
    > Solution:
    > Allocate from the heap, and take the performance hit.
    >
    >
    > ********************************
    > <<< file 1: zend_execute.c
    > >>> file 2: fixed_zend_execute.c
    > ********************************
    > -----[1015 changed to 1015]-----
    > < EX(Ts) = (temp_variable *)
    > do_alloca(sizeof(temp_variable)*op_array->T);
    > ---
    > > EX(Ts) = (temp_variable *)
    > emalloc(sizeof(temp_variable)*op_array->T);
    > -----[1711 changed to 1711]-----
    > < free_alloca(EX(Ts));
    > ---
    > > efree(EX(Ts));


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Moriyoshi Koizumi Guest

  3. #3

    Default Re: [PHP-DEV] PHP thread stack problem on HPUX

    I commited this patch.

    Andi

    At 12:58 PM 19/7/2003 +0900, Moriyoshi Koizumi wrote:
    >Possibly better one (not tested):
    >
    >Index: Zend/zend.h
    >================================================= ==================
    >RCS file: /repository/ZendEngine2/zend.h,v
    >retrieving revision 1.210
    >diff -u -r1.210 zend.h
    >--- Zend/zend.h 10 Jun 2003 20:03:24 -0000 1.210
    >+++ Zend/zend.h 19 Jul 2003 03:54:19 -0000
    > -146,7 +146,7
    > # endif
    > #endif
    >
    >-#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) &&
    >!(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE))
    >+#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) &&
    >!(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) &&
    >defined(NETWARE)) && !defined(HPUX)
    > # define do_alloca(p) alloca(p)
    > # define free_alloca(p)
    > #else
    >
    >Moriyoshi
    >
    >
    >"NAIK,ROSHAN (HP-Cupertino,ex1)" <roshan.naikhp.com> wrote:
    >
    > >
    > > Solution:
    > > Allocate from the heap, and take the performance hit.
    > >
    > >
    > > ********************************
    > > <<< file 1: zend_execute.c
    > > >>> file 2: fixed_zend_execute.c
    > > ********************************
    > > -----[1015 changed to 1015]-----
    > > < EX(Ts) = (temp_variable *)
    > > do_alloca(sizeof(temp_variable)*op_array->T);
    > > ---
    > > > EX(Ts) = (temp_variable *)
    > > emalloc(sizeof(temp_variable)*op_array->T);
    > > -----[1711 changed to 1711]-----
    > > < free_alloca(EX(Ts));
    > > ---
    > > > efree(EX(Ts));
    >
    >
    >
    >--
    >PHP Internals - PHP Runtime Development Mailing List
    >To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Andi Gutmans Guest

  4. #4

    Default Re: [PHP-DEV] PHP thread stack problem on HPUX

    On Sat, 19 Jul 2003, Andi Gutmans wrote:
    > I commited this patch.
    Note that the post concerned the _thread_ stack limit. As
    such, !(defined(ZTS) && defined(HPUX)) sounds more
    reasonable.

    - Sascha

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Sascha Schumann Guest

  5. #5

    Default Re: [PHP-DEV] PHP thread stack problem on HPUX

    At 02:20 PM 19/7/2003 +0200, Sascha Schumann wrote:
    >On Sat, 19 Jul 2003, Andi Gutmans wrote:
    >
    > > I commited this patch.
    >
    > Note that the post concerned the _thread_ stack limit. As
    > such, !(defined(ZTS) && defined(HPUX)) sounds more
    > reasonable.
    Yes you are right. I thought that this concerns all threads including the
    main thread in a single threaded process.

    Andi


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Andi Gutmans Guest

Similar Threads

  1. Mysql-DBD Perl module Installation Problem in HPUX
    By smsabu2002@yahoo.com in forum PERL Modules
    Replies: 1
    Last Post: June 30th, 05:59 PM
  2. Newbie:Using ASP.NET thread pool thread to dispatch TCP data, etc.
    By Navin Mishra in forum ASP.NET Web Services
    Replies: 0
    Last Post: March 22nd, 06:45 PM
  3. ER problem HPUX - Linux
    By Sjaak van Esdonk in forum Informix
    Replies: 2
    Last Post: November 17th, 06:49 AM
  4. DBD::Oracle installation problem at HPUX
    By porschberg in forum PERL Modules
    Replies: 0
    Last Post: November 5th, 02:31 PM
  5. .net thread pooling problem
    By Gary in forum ASP.NET General
    Replies: 0
    Last Post: August 7th, 04:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139