Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92598 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84196 invoked from network); 21 Apr 2016 15:46:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Apr 2016 15:46:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.65 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.65 mail-wm0-f65.google.com Received: from [74.125.82.65] ([74.125.82.65:35962] helo=mail-wm0-f65.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/C1-14036-7C5F8175 for ; Thu, 21 Apr 2016 11:46:15 -0400 Received: by mail-wm0-f65.google.com with SMTP id l6so22489882wml.3 for ; Thu, 21 Apr 2016 08:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=dYkOqYq8nuy0u7iGsbh4ib5FssBiGTeonpL2uG9etn0=; b=ZW9iSYDCz7D710M7zlrnko0ry9vtPCzLEi6KQdlsVDfB9XLpz30yUilUiip07KIM2y wdHRfOu8DbGe1Yg/1LVIj7a9COjOhLZMgWolmEFpd7Gey0a59fruWFeUqeTByELhm31b 7wQqxYGMzbGnggabmAlQFv50mRQaikSP88GjLtKUEaRrOozH2Ia4DdroOl7C5+L+K5s3 ITY6Pd0quyHIzE3xTP6DZzXYeWC5DhE3dCfHCajILxVa4HizKDZHs9pczGf228NFgInW RAMB446HBXR0ggDNyBw/jEJkJh+Yo8b7ENdvx8uRYChIVukHGgewo+8GkQLHbVeGSoEO gFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=dYkOqYq8nuy0u7iGsbh4ib5FssBiGTeonpL2uG9etn0=; b=D0nROPGLSKc0DLSfXoeKStMRnCGGjhuLD6txMtsVQhWdDu6r64BviNSjgCkU0wJvK/ ymslhTXZHdyiJn7Gmld4BP3bd9wOdgUHYOuT0UQnFnYS7d/HhB7V5eLENHldyiWr2Y83 97Y0ghjsaSCYR53DhEPCpAwBXJqiqkSkHNSKmxOaoRHILLYQxjgjxuxfTO1EkiBfyTyl VQTst7+yufovN9k8U5iFdDTt51/49RrOi9NczqAUt+efSDg3d/vS2biysCJqGE6yCO8o FriD5mKkXmlhiPUHvQfWg5ftTxYFYdsVKE0EYWKaS0qUOdx2qTWVVJbOs9qZ3uBwprHJ IbAw== X-Gm-Message-State: AOPr4FWlrjPQ3QvUir1R5U5OhuEv3HZsZNKShlKddlSdYIy0AZmk24+kBzeqijxayCh25WB3cDM0WTkQQvJxJg== X-Received: by 10.28.186.198 with SMTP id k189mr4336989wmf.84.1461253572419; Thu, 21 Apr 2016 08:46:12 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.153.74 with HTTP; Thu, 21 Apr 2016 08:45:32 -0700 (PDT) In-Reply-To: References: Date: Thu, 21 Apr 2016 17:45:32 +0200 X-Google-Sender-Auth: 5JsLxPdAq6aSJCdQxFG-sY_YXe0 Message-ID: To: Dmitry Stogov Cc: Nikita Popov , Rasmus Lerdorf , Anatol Belski , Antony Dovgal , Zeev Suraski , Xinchen Hui , internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Safe timeout handling From: jpauli@php.net (Julien Pauli) On Wed, Apr 20, 2016 at 12:58 PM, Dmitry Stogov wrote: > Hi, > > > It's a well known PHP problem, that exceeding of execution time-out (max_execution_time) may lead to unexpected crashes. > > They occur because PHP may be interrupted in inconsistent state, and attempt to release allocated by request resources leads to failure. > > Almost any big site sees these crashes from time to time. > > > I propose to delay actual request termination until a "safe" point in interpreter. > > Signal handler will just set EG(timed_out) flag. > > Interpreter will check this time from time to time (on jumps and calls that may make loops or recursion) and perform the actual termination. > > This approach already works in PHP for Windows. > > > In addition I introduce hard_timeout (default value 2 seconds). > > In case the "soft" timeout wasn't handled "safely" in that 2 seconds (because of long running internal function), PHP process will be terminated without attempt to free any resources. > > ZTS build will ignore "hard_timeout" (in the same way as PHP on Windows do). > > > The PR: https://github.com/php/php-src/pull/1876 > > > It removes "exit_on_timeout" ini directive, and introduces "hard_timeout" instead. > > Additional checks in VM make 0.5-1% slowdown in term of instruction retired reported by callgrind. > > I think we don't need RFC for this. This is a long time desired fix. > > > The same "interrupt" handling mechanism in the future may be reused for TICK and signal handling. > > > Thanks. Dmitry. Hi ! Good new. No RFC needed, but that breaks ABI and could impact extensions. So, 7.1 as target is OK, not 7.0 Julien.P