# Weird engine problem

- Thread: https://externals.io/message/12938
- Original archive: https://news-web.php.net/php.internals/12938
- Started by Sebastian Bergmann on 2004-09-22T19:52:18+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12938 — Sebastian Bergmann — 2004-09-22T19:52:18+00:00

URL: https://externals.io/message/12938#12938

For quite a while I have been fighting with what I believe to be a bug in
 the Zend Engine 2.

 In PHPUnit2 I have the following code:

   public function run(PHPUnit2_Framework_Test $test) {
       // $test->name: string(14) "testGetBalance"
       $this->startTest($test);

       try {
           // $test->name: string(14) "testGetBalance"
           $test->runBare();
       }

       catch (PHPUnit2_Framework_AssertionFailedError $e) {
           // $test->name: string(14) "testgetbalance"
           $this->addFailure($test, $e);
       }

       catch (Exception $e) {
           // $test->name: string(14) "testgetbalance"
           $this->addError($test, $e);
       }

       // $test->name: string(14) "testgetbalance"
       $this->endTest($test);
   }

 The object referenced by the variable $test has a private attribute
 called "name". The value of this attribute somehow get lowercased
 when the object is used inside the catch-block.

 My effort to come up with a small, reproducing script for this issue
 has yet to bear fruit as the obvious approach

   <?php
   class Foo {
       private $bar = 'BAR';
   }

   class Bar {
       public function doSomething(Foo $foo) {
           var_dump($foo);

           try {
               var_dump($foo);
               throw new Exception('...');
           }

           catch (Exception $e) {
               var_dump($foo);
           }

           var_dump($foo);
       }
   }

   $f = new Foo;
   $b = new Bar;
   $b->doSomething($f);
   ?>

 does not show the problem.

 Any idea what I might be missing here? Is there some way to debug the
 engine to see where the lowercasing happens?

 Thanks!

-- 
Sebastian Bergmann                      http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

---

## #12940 — Marcus Boerger — 2004-09-22T20:53:49+00:00

URL: https://externals.io/message/12938#12940 · In reply to: #12938

Hello Sebastian,

Wednesday, September 22, 2004, 9:52:18 PM, you wrote:

>  For quite a while I have been fighting with what I believe to be a bug in
>  the Zend Engine 2.

>  In PHPUnit2 I have the following code:

>    public function run(PHPUnit2_Framework_Test $test) {
>        // $test->name: string(14) "testGetBalance"
>        $this->startTest($test);

>        try {
>            // $test->name: string(14) "testGetBalance"
>            $test->runBare();
>        }

>        catch (PHPUnit2_Framework_AssertionFailedError $e) {
>            // $test->name: string(14) "testgetbalance"
>            $this->addFailure($test, $e);
>        }

>        catch (Exception $e) {
>            // $test->name: string(14) "testgetbalance"
>            $this->addError($test, $e);
>        }

>        // $test->name: string(14) "testgetbalance"
>        $this->endTest($test);
>    }

>  The object referenced by the variable $test has a private attribute
>  called "name". The value of this attribute somehow get lowercased
>  when the object is used inside the catch-block.

>  My effort to come up with a small, reproducing script for this issue
>  has yet to bear fruit as the obvious approach

>    <?php
>    class Foo {
>        private $bar = 'BAR';
>    }

>    class Bar {
>        public function doSomething(Foo $foo) {
>            var_dump($foo);

>            try {
>                var_dump($foo);
>                throw new Exception('...');
>            }

>            catch (Exception $e) {
>                var_dump($foo);
>            }

>            var_dump($foo);
>        }
>    }

>    $f = new Foo;
>    $b = new Bar;
>    $b->doSomething($f);
>    ?>

>  does not show the problem.

>  Any idea what I might be missing here? Is there some way to debug the
>  engine to see where the lowercasing happens?

>  Thanks!

> -- 
> Sebastian Bergmann                      http://www.sebastian-bergmann.de/
> GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69


Disallow inlining and set a breakpoint on zend_str_tolower_copy() is most
likely responsible for downcasing if the engine is the problem....


Best regards,
 Marcus                            mailto:helly@php.net

---

## #12943 — Sebastian Bergmann — 2004-09-23T05:52:41+00:00

URL: https://externals.io/message/12938#12943 · In reply to: #12938

Sebastian Bergmann wrote:
> In PHPUnit2 I have the following code:

 It seems that I have been at slightly the wrong code

   try {
       $class  = new ReflectionClass($this);
       var_dump($this);
       $method = $class->getMethod($this->name);
       var_dump($this);
       exit;
   }

   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testGetBalance"
   }
   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testgetbalance"
   }

 So it looks like calling getMethod() on a ReflectionClass object for
 the current object lowercases the contents of the variable that is
 passed to it.

 Hardcoding the getMethod() parameter prevents the lowercasing

   try {
       $class  = new ReflectionClass($this);
       var_dump($this);
       $method = $class->getMethod('testGetBalance');
       var_dump($this);
       exit;
   }

   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testGetBalance"
   }
   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testGetBalance"
   }

 while copying the value from $this->name to $name and passing that to
 getMethod() does not

   try {
       $class  = new ReflectionClass($this);
       var_dump($this);
       $name = $this->name;
       $method = $class->getMethod($name);
       var_dump($this);
       exit;
   }

   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testGetBalance"
   }
   object(BankAccountTest)#38 (2) {
     ["codeCoverageInformation:private"]=>
     array(0) {
     }
     ["name:private"]=>
     string(14) "testgetbalance"
   }

 Sorry for these lengthy mails but this issue is important to me as it
 hinders the development of PHPUnit2.

-- 
Sebastian Bergmann                      http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

---

## #12948 — Sebastian Bergmann — 2004-09-23T14:27:16+00:00

URL: https://externals.io/message/12938#12948 · In reply to: #12943

Sebastian Bergmann wrote:
> Sorry for these lengthy mails but this issue is important to me as it
> hinders the development of PHPUnit2.

 Since I was finally able to write a small reproducing script I opened a
 bug report for this: http://bugs.php.net/bug.php?id=30209

-- 
Sebastian Bergmann                      http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69
