Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106118 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49145 invoked from network); 30 Jun 2019 00:47:54 -0000 Received: from unknown (HELO mail-lj1-f169.google.com) (209.85.208.169) by pb1.pair.com with SMTP; 30 Jun 2019 00:47:54 -0000 Received: by mail-lj1-f169.google.com with SMTP id r9so9318266ljg.5 for ; Sat, 29 Jun 2019 15:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vovZsZx2RjRJszg9dbqmTpUe3I/BiO9o/elgOvS6Ljs=; b=sxCqfFjE6roCcsP0Q0paidE1clAQouZlgR6yhDL8JMcAftY/sfFMnjTrQQlJceXraW kTm0pvp1X35bInptq2B4gGbfqt4VqT5pkSi/dxbPB5lcHz43jFNItxM/e0Sp3ECH4ZLh UlgVT6RRz37Fzfp7APsyPa/VsLs1BM1oRRmbHlc5mgEEjwCbaEth2sF8ltuNigwB3nM+ tIDXwdenR6JzMQ+4q8VvHL1WmVzKwP+Btr08LJfHNtSE4Qsex+2sI7fUGdebbdw3PqeP /CbadhherpTme62wSiiFGH1FNtj+4PN2I7QMtq7s14wvraDVHH7pspv0jnjfH9esESyr UCgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vovZsZx2RjRJszg9dbqmTpUe3I/BiO9o/elgOvS6Ljs=; b=DIT7d3dK/aAtAMrh3I2hCJuW04GU7ICBb/oh7fT+KwiLsp6cP061jMJqvg9DigvStp z9mUX9rKUGpTkRir50256BmYEMwvI3G0vJy8Ckzg0Zq5nUzRGyP65oR/bj5sn9s+5jmd zBv3/swzvGkU+7IP6S67kOvnHx/7sNUDxXt/SHmZPXONx9PasLKdKPbRrH8lySn4oO3L JlfBmFFqaB4oEpaL7y8jlCZwc4hoPrpceHs4xUZD1wZ2Q/kdbusV1WKB/EH5rc6A6b7e mF3jMV+aaMXw8cR6RGAd9al3TQoYCD3le0QWwcONw6cSIYeamMNfQ+GP07d9leAIIMuV w1/A== X-Gm-Message-State: APjAAAXCiuGIB3dymDz4TRqncw1ZJouBSddnpmmSY92b+hQNGp/YYNTY RQ+euHde+tM/DVVdL7F34JLc0m+kYE+kQi0tBDI= X-Google-Smtp-Source: APXvYqxvZ9JkbcZtiL1lcPL/WHmWxXY9JwJyze9/pXuszm89EPtXVXCQb8SEZPMeOgNpGYphJx3vNQwz/j43z/e7EZM= X-Received: by 2002:a2e:89c8:: with SMTP id c8mr9941846ljk.70.1561845908657; Sat, 29 Jun 2019 15:05:08 -0700 (PDT) MIME-Version: 1.0 References: <8f07c0dc-f9a5-8c76-1d48-0fac762bfc4f@gmail.com> <92dba455-17df-41dd-c523-bb0db3c12078@gmail.com> <003b01d52e49$4db89390$e929bab0$@jhdxr.com> <000001d52e8f$a1f92b40$e5eb81c0$@jhdxr.com> In-Reply-To: Date: Sun, 30 Jun 2019 00:04:52 +0200 Message-ID: To: David Walker Cc: Benjamin Morel , CHU Zhaowei , PHP Internals , Stanislav Malyshev Content-Type: multipart/alternative; boundary="000000000000945baa058c7d96e2" Subject: Re: [PHP-DEV] Memory leak in eval()'d code From: nikita.ppv@gmail.com (Nikita Popov) --000000000000945baa058c7d96e2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jun 29, 2019 at 11:56 PM David Walker wrote: > > > On Sat, Jun 29, 2019 at 15:52 Nikita Popov wrote: > >> On Sat, Jun 29, 2019 at 11:25 PM Benjamin Morel > > >> wrote: >> >> The leaked memory is an allocated but unused class >> entry. We could plug that particular leak -- but I should emphasize that >> the current behavior is incorrect and once the key collision issue is >> resolved this will create a new class for each eval. > > > To clarify; you=E2=80=99re saying that the behavior seen in the non scale= d case is > kind of =E2=80=9Cwrong=E2=80=9D in the sense that it=E2=80=99s exposing t= he big in naming of the > anon class. Once the bug is resolved, the two behaviors shown should mimi= c > each other, wherein the memory footprint would grow as in the example > eval() case. > What is the "non scaled case"? To repeat what I said earlier: Without eval there is no and will not be a leak. The bug is that eval() currently reuses an existing class instead of creating a new one each time. Calling get_class(eval("return new class {};")) should be returning a new string every time, while for OPs script it currently does not. tl;dr: while (1) { get_class(new class {}); // should always return the same get_class(eval("return new class {};")); // should always return different, currently may return same due to bug } Nikita --000000000000945baa058c7d96e2--