Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124340 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 1BD5B1A00B7 for ; Wed, 10 Jul 2024 10:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720608536; bh=ZdavOjsMXkhXgjJDHcsgxlo3lFVvgAxtb1+91c7Sb8A=; h=References:In-Reply-To:From:Date:Subject:To:From; b=bPZ8vyPjV1iFrJQqGP+5Ej23csU0YBlsvkOPxewbHvKIoz7tpdMyTXXzVBNXxfkD0 QwJ+5c1aJ8uOVQo8o+igrls9HCRXy9zuz3TJu9gpGUS9cYxg2ndx0IXQVN5MCy7BWP HobFI5YM1eurKKQCw2UC8/XLM4IjN6JyTGoKs1qexWWynHLEhEbQHyYUUIX67OLuk1 mp8Bz04Awcm7fVmCyLU5XmdocXT7FxODrrTODKI+7rxMzA3uKip8KHwaYhuTizRRfz UBInw+FLY9yaZfoyOwjhNrsUdEjGwUWFJQobk+ZOxQs3Nd1mDu2c8YijbSQ9FLg1E7 OfYX/zQ/oY/aw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 23120180642 for ; Wed, 10 Jul 2024 10:48:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 10 Jul 2024 10:48:55 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6b6176e59e7so14041376d6.1 for ; Wed, 10 Jul 2024 03:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720608449; x=1721213249; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sjoYWboI4fKfefcrllIQGcsTonB3euXCpwxoN4rq5lk=; b=dSydawTXOM2pRGcPmZaeY5z1B++Aswcv0xm8BaKc3rtbZqWQ2T/JduDyOvISipQUCN 6UU5TQF4NlkO5LUnTD1wDqLk1cjgFeeD6B33WM66VhJ3miwsxOZF3hMlMAEQkvqJbW18 /quvG46jiM+zu80IEMaq++iw9rSLpOoyCjrwlRNv6YRwg+6Hhqd6llqnIoWU3b1Jt400 xoKpQfxWdtHadpeJ+ibHK+Og6pmlgpcyeVRAPRnxiHZnWGOGmn9sYlEYbjVfkyMNkCAy lz8m9yeZXLqjCtB5Lv5nUuT6sfP8YZomFjQO75I2d281n4UF4pzazY5hjQMimYMxmlNC 9dhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720608449; x=1721213249; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sjoYWboI4fKfefcrllIQGcsTonB3euXCpwxoN4rq5lk=; b=WJwnwT7aztnGkjXEoGc+54Tco8uucXWvvBrxxUUlRoyOHTBMNV9Xj6mEcnqnhSgAiY qGqD+PyaLNKkJvxnzK/PY8bszm2Joz1ckn3v16KdVeUJCPtzTYb3+JFfFlKyeJAf6QPx mjfBdtv82P0izGRDBelM6GQqJSloXNwG8JwtId3Eogo27osLhIla8iy5SszMFEp7WqVh WH4eqZlTYhBlks1qTGc6XrlWlfDNkAdIvBZKmetqsO++F1EFMsdMR+RK2xLbJShA6u8A H5fH45R5A7vRfUV7a91Wc7t9pm4I7myWvWeDGQRC1AA7IFEB3t+v+JzAkKZxYEHlF3hI fpDA== X-Gm-Message-State: AOJu0YzjtI/ZcPQSPv9z3sWeeLQs9or03zIkPbkScq1pGPlv1I8wB90C HqNSnyOjlffKi3TREGByWJpq/ZXiy4g1AUprQZVELNM18KD4g4EHwfe4hrAGZMJYP9eQbI3SW0o ZR4jJ9f5GPVSii7oSa/ms4QXpwv4cW/HeM40= X-Google-Smtp-Source: AGHT+IHqpKFqWE2XNGdB5xhzjsTwT9ie2qaCBvKgHgNYqg0mRrXLk3+uG63v4er0QwmgAw01Cb+pryREx6PxjyPhrDA= X-Received: by 2002:a05:6214:5098:b0:6b2:dd54:b634 with SMTP id 6a1803df08f44-6b61bf68be9mr51161326d6.39.1720608449086; Wed, 10 Jul 2024 03:47:29 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <520ee513-d6fe-a658-5845-00296a9e08a2@php.net> In-Reply-To: <520ee513-d6fe-a658-5845-00296a9e08a2@php.net> Date: Wed, 10 Jul 2024 12:47:18 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Property Hook improvements To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Derick On Wed, Jul 10, 2024 at 11:32=E2=80=AFAM Derick Rethans wr= ote: > > On Mon, 1 Jul 2024, Larry Garfield wrote: > > > > > https://wiki.php.net/rfc/hook_improvements > > 1. Remove the proactive guard against recursive backing value access > > "which would eventually trigger a stack overflow" > > Would it though? PHP 8.4 has an actual protection against this now, > instead of getting the white-screen-of-death. > > Not that it matters much, but it's probably good to be precise in the > language. Yes, this excerpt is referring to the PHP stack overflow detection, which will throw an exception rather than segfault. That is, on all the architectures that already support stack overflow detection. We're just reusing the same mechanism already used for normal function calls. --- Hi Claude > 1. Removing the guard against recursion is sensible to me, as the sort of= bug it is supposed to prevent is not specific to property accessors. IMO, = a better solution to the issue is to implement a global upper limit on the = call stack size. Currently, I am able to generate a call stack of more than= 10 millions items before an OOM error occurs; PHP should have thrown a sta= ck overflow error long before that. But this is entirely orthogonal to prop= erty hooks. PHP allows using recursion for algorithms on arbitrarily large data because function calls do not cause the C stack to grow. Limiting the PHP stack size would thus require these algorithms to be rewritten to iterative ones, which can make them more complicated. What we could do is check for stack size on OOM and indicate that the OOM was most likely caused by infinite recursion. Anyway, This does not really apply to hooks, because it will (usually) cause VM reentry for recursion, growing the stack size and thus triggering the "fast" stack overflow detection error. Ilija