Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101975 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27269 invoked from network); 13 Mar 2018 15:12:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2018 15:12:35 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.216.172 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.172 mail-qt0-f172.google.com Received: from [209.85.216.172] ([209.85.216.172:33835] helo=mail-qt0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/15-24487-06AE7AA5 for ; Tue, 13 Mar 2018 10:12:33 -0500 Received: by mail-qt0-f172.google.com with SMTP id l25so23093492qtj.1 for ; Tue, 13 Mar 2018 08:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=AkodUezAwMFxHwYKRPI5IAzIcViPHYihhJRDrtn5obI=; b=TTOPMfj4BgD9iIpHR1ZiV505AYHBZU164Zvhd5x5PWzYsfLJ1lIE1e0kloZtDnU/Kw EyIPqCjkwRA4yICQYRWu9OKECaTIiI+KPRbMqttXbSSLBA41jPZxtQYKQyg8wRjjP4ud vlcMpxbQmkwdCf5oFCZelh4Scc5f2I9LaYllL9nen6jPeJQxd/kStIYTmSStQD+NMzvR baO0n3qrzmrnzbiPCBsvwV7VimWfzmGBF0DgKyyROQggogJfuxtytnAVP9rmwuPZkZuh l1nDUX5NpcnVji5fmsyZsFP5jofpjHdcc9rXcM2RBYzW/qeVhKYsLQAAh/1ktcNEEB7N TcrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=AkodUezAwMFxHwYKRPI5IAzIcViPHYihhJRDrtn5obI=; b=dbDviTsNV79ouFw2CR0II5+N7Aa5ju/Qg/NcTZWr0597fEF22W44SfnGI/gTk05Vw1 B9HtUxmHsSDlUsdMx2r7E4FcWoEy2WN5UKnMnVqJKt3Btg2m63LPhciY7FNomeJAyjJ4 P4Fn+hVQDu3U4wuBsJKimcZaw766nUO+mufbEpLugOka8XlpjqXktkkvrREN7Oy6aBeu kkRSBUY9hZNcWgsQfGfB19e+v1fXorqpd2rAuZpuNXeDASvnW/wPbxVoy+TbB+iPIldI QAGv6DFagRoUrdayFS/a41WK9Hb6e7GqZcBVGoZRz6nVLGriHdbCUTTRHOJnl+uFZjsS O+NQ== X-Gm-Message-State: AElRT7G1lifPuViuoaN9thxy9YGMVt/SXiw8yalIbXzV+uuOnlRpeH9g PkNRZ5PUINF6UAAoAkptnr2GCt/qB0IbbpcBJAmNIdP/ X-Google-Smtp-Source: AG47ELuuotYulVetUYIdgB69g5b2fSYaBy0cCeEfW/c9ntw7JgDIQs9Wx0nmMbtGvsVXz7bosqJUg1wTixjokEwfZr8= X-Received: by 10.200.44.114 with SMTP id e47mr1530825qta.59.1520953950526; Tue, 13 Mar 2018 08:12:30 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.155.169 with HTTP; Tue, 13 Mar 2018 08:12:29 -0700 (PDT) X-Originating-IP: [71.251.16.204] In-Reply-To: <20180313085256811754.b59ffa5c@klingler.net> References: <64.2E.24487.2D7A6AA5@pb1.pair.com> <20180313085256811754.b59ffa5c@klingler.net> Date: Tue, 13 Mar 2018 11:12:29 -0400 X-Google-Sender-Auth: ckxdBBfVnxYuloC_sPl1BVUe5Sg Message-ID: To: Richard Klingler Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Migrating php extension from 5 to 7, ZVAL_STRINGL no value returned From: pollita@php.net (Sara Golemon) On Tue, Mar 13, 2018 at 3:52 AM, Richard Klingler wrote: > Hello Sara > The function macro itself is defined as: > > ZEND_FE(readmydevice, NULL) > > So would the arg_info go in here? There isn't any arg_info in the original code. > Yep. You'll want something like this: ZEND_BEGIN_ARG_INFO(arginfo_readmydevice, 0) ZEND_ARG_INFO(0, device) ZEND_ARG_INFO(1, string) ZEND_ARG_INFO(0, length) ZEND_END_ARG_INFO(); ZEND_FUNCTION(readmydevice) { /* do your stuff to build p and mycount */ zval_dtor(z); ZVAL_STRINGL(z, p, mycount); /* finish up */ } zend_function_entry whateveryoucallit[] = { /* other FEs.... */ ZEND_FE(readmydevice, arginfo_readmydevice) /* other FEs... */ ZEND_FE_END }; That "1" in ZEND_ARG_INFO(1, string) is what tells the engine that the argument is pass-by-ref. You should have had this in PHP 5 as well. It *appeared* to work purely by the accident of how you were calling it from userspace. The reality is that you could easily have wound up with memory leaks and/or "randomly" changing values unrelated to your initial variable. I assume your extension isn't open source or you'd have linked it by now, but if you can share it, I'd be happy to offer other suggestions. Based on what I've seen so far, I'm willing to bet there are other small, subtle bugs hiding in there. -Sara P.S. - Side benefit of defining these arginfo structures is that ReflectionFunction will actually give you parameter info now.