Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110733 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71240 invoked from network); 26 Jun 2020 12:32:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Jun 2020 12:32:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C5115180088 for ; Fri, 26 Jun 2020 04:20:22 -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.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 26 Jun 2020 04:20:22 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id 9so9933302ljv.5 for ; Fri, 26 Jun 2020 04:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=/S0gjm+FFmbrqL9jZnfyduMwf8F5umerV2QcUgqDELg=; b=fh9DPMrZ7bwlgXr97XM3frZRQyDtG3rlYV5yyo5NahwHdzLKZb1f9g/sQz6JGlhlYT QkozdSMRVt3Fwp2awspHv3bv/iSmh6ekbcFXjRw0r4zmrg13DMAWMcLnk3R5hm51D9bM E9eHK9+Xzi6DDfvI0jbitkARyeTMn/NYRaKJkx8UcXdwXkNd+mH9nQKNq6uysEtNHX5v 9QBaqMmumFOrbdVlkO1Fsq4nhLNRlLZ2JblkpKWylAjw34Jv91ggYKZQx3r/9AXLAIcz BcjaI/hXPAis34EV/c/oZpkMpw67iiId/it10AmFX4xrQAhc91LFeYBRqwgVOrJ/sRyq +5GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=/S0gjm+FFmbrqL9jZnfyduMwf8F5umerV2QcUgqDELg=; b=evjcbgt+SJcnMgUv7WeXAm3xkiUxeUsWjaRqbTK8UDuu1stTeH8SW1WaDZ/YUaE5nV LQQzmIpKOUmZ387T7ginT6vOtYwNoRKGZT7m5CVvxcQfBq4ZXZBKwqQr0BUWvjtCE49x s5M1/KMkTulGdrTQAF/tT73mTw0Kkj1benuDIlKzR7mGE/H8SfllbNsGFWXMzeoLNjVg bC4sJqaNE1KxtknugHGBmj25NYKFU5Bo7ffdLyu5OgI8Ri+7d2yBlmGwSRoCh/WeIOzp p1z3A2Ver/0dV4tYY3/prdWwaiEzBY6TCFUhgAdqwtNy+BsVFXpImmj3cQx3X+Tb4n6z nR7Q== X-Gm-Message-State: AOAM530YL57Nthj+Ned5YofvgA+m+jz4UJI6gW/FRcA2UyeL0wqwvu+P IdEYGK3MVFvO5OIkGL6MuHwMpFuM X-Google-Smtp-Source: ABdhPJxQ8Dglo+1U3t7O/39VJmr65vGQEa9kXIJt0oIqhZgKAJ7E8UbaY6oGjN0NQIE+WHsqIfvoCg== X-Received: by 2002:a2e:8490:: with SMTP id b16mr1236673ljh.325.1593170419607; Fri, 26 Jun 2020 04:20:19 -0700 (PDT) Received: from ?IPv6:2a02:aa7:400a:8a23:4443:3d1:9caa:e5cc? ([2a02:aa7:400a:8a23:4443:3d1:9caa:e5cc]) by smtp.gmail.com with ESMTPSA id f129sm6711004lfd.6.2020.06.26.04.20.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jun 2020 04:20:18 -0700 (PDT) To: internals@lists.php.net Message-ID: <3bae7e6c-d7a4-ac28-00e8-b752eebcab13@gmail.com> Date: Fri, 26 Jun 2020 13:20:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Thunderbird/79.0a1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: PHP Bug #79714 From: henry.wood.dk@gmail.com (Henrik Skov) Hi list ! I am still trying to solve bug 79714 (See: https://bugs.php.net/bug.php?id=79714) I am no expert at C and/or the PHP Core at all so I need a little advice from you guys. Seeing lines 3238-3314 in /ext/phar/phar.c (from php-src repo): static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) /* {{{ */ {     zend_op_array *res;     char *name = NULL;     int failed;     phar_archive_data *phar;     if (!file_handle || !file_handle->filename) {         return phar_orig_compile_file(file_handle, type);     }     if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) {         if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL)) {             if (phar->is_zip || phar->is_tar) {                 zend_file_handle f = *file_handle;                 /* zip or tar-based phar */                 spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php");                 if (SUCCESS == phar_orig_zend_open((const char *)name, &f)) {                     efree(name);                     name = NULL;                     f.filename = file_handle->filename;                     if (f.opened_path) {                         efree(f.opened_path);                     }                     f.opened_path = file_handle->opened_path;                     f.free_filename = file_handle->free_filename;                     switch (file_handle->type) {                         case ZEND_HANDLE_STREAM:                             if (file_handle->handle.stream.closer && file_handle->handle.stream.handle) { file_handle->handle.stream.closer(file_handle->handle.stream.handle);                             }                             file_handle->handle.stream.handle = NULL;                             break;                         default:                             break;                     }                     *file_handle = f;                 }             } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {                 zend_file_handle_dtor(file_handle);                 /* compressed phar */                 file_handle->type = ZEND_HANDLE_STREAM;                 /* we do our own reading directly from the phar, don't change the next line */                 file_handle->handle.stream.handle  = phar;                 file_handle->handle.stream.reader  = phar_zend_stream_reader;                 file_handle->handle.stream.closer  = NULL;                 file_handle->handle.stream.fsizer  = phar_zend_stream_fsizer;                 file_handle->handle.stream.isatty  = 0;                 phar->is_persistent ? php_stream_rewind(PHAR_G(cached_fp)[phar->phar_pos].fp) :                     php_stream_rewind(phar->fp);             }         }     }     zend_try {         failed = 0;         CG(zend_lineno) = 0;         res = phar_orig_compile_file(file_handle, type);     } zend_catch {         failed = 1;         res = NULL;     } zend_end_try();     if (name) {         efree(name);     }     if (failed) {         zend_bailout();     }     return res; } I *think* that what maybe would fix this bug is if line 3299 (res = phar_orig_compile_file(file_handle, type);) was - if BCGEN extension is loaded - is affected so that phar_orig_compile_file was changed to point to another function. Let's imagine that phar_orig_compile_file pointed to bcgen_phar_compile_file() which was then implemented by BCGEN: ZendAccelerator.h (of BCGEN): (Link: https://github.com/vjardin/bcgen/blob/a863b8d596cebb698a491f7475903f5aa3664719/ZendAccelerator.h) zend_op_array *bcgen_phar_compile_file(zend_file_handle *file_handle, int type); ZendAccelerator.c (of BCGEN): (Link: https://github.com/vjardin/bcgen/blob/a863b8d596cebb698a491f7475903f5aa3664719/ZendAccelerator.c) zend_op_array *bcgen_phar_compile_file(zend_file_handle *file_handle, int type) {     if (!file_handle->filename || !ZCG(enabled) || !accel_startup_ok) {             /* The Accelerator is disabled, act as if without BCGEN */         return zend_compile(file_handle, type);     } else {         /* Use the zend_compile replacement of BCGEN for this file */         return persistent_load_file(file_handle, type);     } } Now, for my question: How can I make sure that phar_orig_compile_file() points to bcgen_phar_compile_file() when line 3299 of /ext/phar/phar.c is hit *WITHOUT* changing line 3299 if - and only if BCGEN module is present ? Would a #define do it ? (something like: #define phar_orig_compile_file bcgen_phar_compile_file in ZendAccelerator.h (of BCGEN) (Link: https://github.com/vjardin/bcgen/blob/a863b8d596cebb698a491f7475903f5aa3664719/ZendAccelerator.h) NOTE: /ext/phar/phar.c already has this on line 3230: zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type); which would conflict with my - proposed - define/solution or ? Please advice ! If it is inappropriate to ask for coding advice on this list, I do apologize for this mail ! Thank you in advance ! Best regards, Henrik Skov Secuno A/S