Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84592 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37799 invoked from network); 11 Mar 2015 22:33:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2015 22:33:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.176 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.176 mail-vc0-f176.google.com Received: from [209.85.220.176] ([209.85.220.176:46778] helo=mail-vc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/C7-32765-9C2C0055 for ; Wed, 11 Mar 2015 17:33:47 -0500 Received: by mail-vc0-f176.google.com with SMTP id kv7so4110481vcb.7 for ; Wed, 11 Mar 2015 15:33:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=5aWIWqIl7Pc/Ab9ZzwAH2uujWu5jewftNZFCl8d7IY0=; b=U+0Hgvs78in0/OIGjZOUYnKnUG241xO7n4HQ4SphqYEg/2sUhNcAE6cI2ZTNnDypYh 0uIK9caKsutyNJfUrpL6QX7NR8ZnoYoLrKhWWJIy7vUYOYABgrVp84YO2iRweIQU3WDz f155E4t/eCV7bCM2pvRVG9D6wvMLQ9/USzE5ySIW9jnp/R7toupquKVNf5sRfpNgDd7O r7d0w6R9nInF20+LDC34QnSQHadnpo97MeHGw3V6sR1uzxCy4IOR5kbF4JDxmhnc5k+R LHw1T3mqxLJV1GVvaDFKIQFaYIslUbyrDl6bcmAIgOqOYLw30Uz7hyq/RI3yswEZXciF 2pdg== X-Gm-Message-State: ALoCoQlOplJETByBNRd7RLvGNCQtze17qnoPIIuxgtZNaDx7dOezS8gxM9+6SGBRomeP4Ru/EO/Sjpg9PnXq5gbCteVL7pWidwrX4Ga3ha20yPqPv2qzb79oG2mduDea8eEoL5+nqImvTqv5E3ZeZvWYorvqh6pjNw== MIME-Version: 1.0 X-Received: by 10.52.52.136 with SMTP id t8mr45341938vdo.49.1426113223218; Wed, 11 Mar 2015 15:33:43 -0700 (PDT) Received: by 10.52.113.231 with HTTP; Wed, 11 Mar 2015 15:33:43 -0700 (PDT) In-Reply-To: <5500C04D.9000805@gmail.com> References: <5500C04D.9000805@gmail.com> Date: Thu, 12 Mar 2015 01:33:43 +0300 Message-ID: To: Stanislav Malyshev Cc: Rasmus Lerdorf , Nikita Popov , Xinchen Hui , Anatol Belski , PHP Internals Content-Type: multipart/alternative; boundary=089e0115f048146ffb05110adc99 Subject: Re: [PHP-DEV] Safe execution timeout handling From: dmitry@zend.com (Dmitry Stogov) --089e0115f048146ffb05110adc99 Content-Type: text/plain; charset=UTF-8 On Thu, Mar 12, 2015 at 1:23 AM, Stanislav Malyshev wrote: > Hi! > > > Instead of throwing zend_error() from signal handler, now we just set > > EG(vm_interrupt) and EG(timed_out) flags. PHP VM checks EG(vm_interrupt) > > flag on each JMPx instruction (potential loop iteration) and then throws > > That looks very nice but makes timeouts much less powerful. I think > without some ability to interrupt internal functions it won't be good. > agree. This is why I ask for ideas. > > > Unfortunately this approach doesn't support interruption of long-running > > internal functions yet. It should be extended in some way. May be > > additional timeout. > > Doing additional setjmp when entering internal function probably would > be too expensive. So the question is how to get out of the bad function > without incurring per-function overhead... Not sure how to do it. > The problem is not in overhead. If we longjmp() from signal handler we always may have something partially uninitialized and this leads may lead to crash on request shutdown and SHM pollution. I think, after "max_execution_time" is exceeded, we may start another "hard_timeout", and in case the EG(vm_interrupt) wasn't handled "safely", kill the process. Thanks. Dmitry. > > -- > Stas Malyshev > smalyshev@gmail.com > --089e0115f048146ffb05110adc99--