Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118859 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 999 invoked from network); 20 Oct 2022 14:11:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Oct 2022 14:11:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 41B101804AC for ; Thu, 20 Oct 2022 07:11:15 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 Oct 2022 07:11:14 -0700 (PDT) Received: by mail-ed1-f48.google.com with SMTP id g27so30093746edf.11 for ; Thu, 20 Oct 2022 07:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas-fr.20210112.gappssmtp.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=+X72mJROJJZPs3rSKahg6Dc0M1/AC8sieI8yHm1tyhA=; b=a0/uvqOVQKyMGV20CqMkedLDGJK+EyXMsjsPn6FjVAwSjCIMW5tdU2oAhpOPzEe2GX rZ7B3fINnH36bzxxcEwHWPAmnlmo4VXbTs8iLzradqEorln+e5FY8X1QbBe9K3XTGULM W4T4SJr6rOHfOS6flQWEnSDTqH2E/C1AMOPzTuA4rMuODpvJ5/6k7x8Pcdh5hfeazql4 fTc5FsFtsKFmgzimIXzxMpmgEmt56E6hcBS8q4Q6x9k7fdQEzggL5ESaWYKaB+4vRY+n 3IznziwDM4zJGcHM+v5ytIZgbHjghHbCavR4h5AqzJfFBoh/JWNoKgQtyyz5tIXeXMsA iQtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+X72mJROJJZPs3rSKahg6Dc0M1/AC8sieI8yHm1tyhA=; b=S4P7VJILSfjH0m+FenEVo2/0MVluuT6PmDEYeTO0zAWELrMWH3xieE+kQzm9/czGlU ppGiJ68hQt0vYeLMwflx3LhOgBrtATiwREsLW/mPXSnz7x9RdprcDZqD43Ppfxs9Jljj L6JPVbbWXoOb3VrhSd6smscyIuVGyUUFGyEskdA0jqG8CtjDFWELJ7jDg+bTHw4MyG7D AhlNjZJdEUlArKljKZZtlzLPoAbYC4KSg96gKIGKkzxWZnhkx2niBHYzwD94xe1vSNPC xmAsuc7miAYWI2yAK6oKuyB9rV8JHnOktWtDc1Gd5rrUGP8p5dOQXX6Yaws69HQ44Jn/ j3fA== X-Gm-Message-State: ACrzQf1/t/WZhxjY/SEKDq29zOEruKOjHF96oPSviPQmcjUTYP8d2qQQ 8EzTOifI99UcCuwE9IjHI1yR9dHyD1dBp1HakAfxkWNw4zLWFw== X-Google-Smtp-Source: AMsMyM5FwjvWQo9LLNYSqNogmg4WrOETuUJ4/omAeX6RUey+NKA+RiC8B+8UQPxFROEwDPd6UyBy9rmXnGAXoeQb9uA= X-Received: by 2002:a05:6402:3551:b0:45d:a52f:2d77 with SMTP id f17-20020a056402355100b0045da52f2d77mr12765590edd.67.1666275073063; Thu, 20 Oct 2022 07:11:13 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 20 Oct 2022 16:11:01 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000d410f605eb77e5e9" Subject: Proposal to incrementally improve timeout and signal handling From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --000000000000d410f605eb77e5e9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Internals, PHP suffers from several issues related to timeout and signal handling, especially when built with ZTS enabled. 1. The current implementation of timeouts on UNIX builds seems "fundamentally incompatible with ZTS" ( https://bugs.php.net/bug.php?id=3D79464#1589205685) and more anecdotally conflicts with some Go features ( https://github.com/golang/go/issues/56260#issuecomment-1281040802) 2. "Zend Signals" causes segmentation faults and other problems in multi-threaded environments ( https://github.com/php/php-src/issues/9649#issuecomment-1264330874, https://github.com/php/php-src/pull/5591#issuecomment-650064098), and seems useless anyway since PHP 7.1 ( https://github.com/php/php-src/pull/5591#issuecomment-645428002) In 2020, Alex Dowad started a major refactoring to improve these parts ( https://github.com/php/php-src/pull/5570, https://github.com/php/php-src/pull/5591, https://github.com/php/php-src/pull/5710), but he stopped working on it. Instead of doing a major one-time refactoring like that, I propose moving forward little by little to limit the risks and the potential backward compatibility breaks. Here is the plan: 1. Switch to timer_create() for timeouts, but only on Linux (it's not supported on other platforms yet), when ZTS is enabled and Zend Signals is disabled. As the feature is currently entirely broken when ZTS is on, this can be considered a bug fix and cannot be worse than it currently is. 1bis. Can be done independently of 1., and even in parallel, optional as long as we keep the --disable-zend-signals flag: Remove Zend Signals entirely, because even if it can be partially fixed (I proposed a patch fixing segfaults: https://github.com/php/php-src/pull/9766), it seems now useless and causes unfixable issues with some signals such as SIGINT ( https://github.com/php/php-src/issues/9649#issuecomment-1265811930) 2. Switch to Grand Central Dispatch on macOS and FreeBSD when ZTS is enabled and Zend Signals is disabled (if not removed at this point), which provides a feature similar to timer_create() for these platforms. 3. Probably in a future major version, optional: switch to timer_create()/GCD even for non-ZTS builds to uniformize and simplify the code. What do you think about this plan? Apart from the technical aspects, what's the best way forward? Submit patches? Propose an RFC? Do both? (pardon my ignorance of internals processes). Thank you, --=20 K=C3=A9vin Dunglas --000000000000d410f605eb77e5e9--