Bug #55382 [Com]: Crash on GLOBALS inside traits

From: Date: Mon, 08 Aug 2011 15:18:31 +0000
Subject: Bug #55382 [Com]: Crash on GLOBALS inside traits
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-162471@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55382&edit=1

 ID:                 55382
 Comment by:         ava3ar at gmail dot com
 Reported by:        ava3ar at gmail dot com
 Summary:            Crash on GLOBALS inside traits
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Gentoo
 PHP Version:        5.4SVN-2011-08-08 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

If you change the test trait to

<?php
trait test {
 function tester($cCookie) { 
  if ($cCookie) {
   if (isset($_COOKIE[$cCookie])) {
    return $_COOKIE[$cCookie];
   }
  }
  return false;
 }
}

//
you get a zend_mm_corrupt


Previous Comments:
------------------------------------------------------------------------
[2011-08-08 15:17:10] ava3ar at gmail dot com

Description:
------------
if you use GLOBAL variables inside traits, e.g. $_COOKIE, it segfaults

Test script:
---------------
<?php
trait test {
 function tester($cCookie = false) { 
  if ($cCookie) {
   if (isset($_COOKIE[$cCookie])) {
    return $_COOKIE[$cCookie];
   }
  }
  return false;
 }
}

<?php
class asda {
 use test;
 function beep() {
  $this->tester("test");
 }
}

$a = new asda();
echo $a->beep();

Expected result:
----------------
false, or contents

Actual result:
--------------
Segfault


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55382&edit=1


Thread (9 messages)

« previous php.bugs (#162471) next »