Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traits related issue #5

Closed
nikita2206 opened this issue Feb 13, 2013 · 7 comments
Closed

Traits related issue #5

nikita2206 opened this issue Feb 13, 2013 · 7 comments

Comments

@nikita2206
Copy link

Hi, Zeev! Glad to hear that Zend Optimizer+ finally open sourced! There's this bug I found, it's actually very strange, because it reproducible fairly easy.
Anyway, there's description:

Environment: Ubuntu 12.04 with PHP compiled, here's php -v output:

PHP 5.4.9 (cli) (built: Feb 12 2013 17:14:19) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
    with Zend Optimizer+ v7.0.0, Copyright (c) 1999-2013, by Zend Technologies

php.ini contents:

include_path=/usr/local/lib/php

date.timezone=Europe/Moscow

extension=amqp.so
;extension=apc.so
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/ZendOptimizerPlus.so

;apc.enabled=1
zend_optimizerplus.enable=1
zend_optimizerplus.memory_consumption=128
zend_optimizerplus.save_comments=1

Code reproducing the bug:

<?php

trait FooTrait
{
    public function foo()
    {
        return "foo";
    }
}


class BarClass
{
    use FooTrait;
}

var_dump((new BarClass())->foo());

Expected output:

string(3) "foo"

First run output:

string(3) "foo"

Second and subsequent runs output:

Fatal error: Call to undefined method BarClass::foo()

This bug is reproducible on fpm, but not on cli.

@zendtech
Copy link
Collaborator

Hi Nikita,

Thanks for comments. Can you reproduce the same problem without xdebug?
I tried your test case with FastCGI SAPI without xdebug, and didn't get any problems.
I suppose it somehow must be related to xdebug, may be caused by extension loading/initialization order...

Thanks. Dmitry.

@zendtech
Copy link
Collaborator

I can't reproduce it even with xdebug (still FastCGI SAPI).
Do I need to set any xdebug configuration directives?
Please, try to localize the problem.

@nikita2206
Copy link
Author

Hello again, yes, sorry for not answering. While you can't reproduce it w/ xdebug, I can reproduce it even w/o it, so I think xdebug is not the one who causes the problem. I'm trying to debug it now, unfortunately I don't have much skills in C (I'm debugging it using zend_printf output...). If it can give you any clue: I found that when zend_class_copy_ctor called, class_entry of BarClass has num_traits equal to zero (on first and all subsequent runs).

If it can help, here's more info about my environment:

uname -a
Linux nikita2206-N56VJ 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

php -i: https://gist.github.com/nikita2206/4951643

@zendtech
Copy link
Collaborator

Traits are added at run-time by ZEND_ADD_TRAIT and ZEND_BIND_TRAITS opcodes, so it's expected that " when zend_class_copy_ctor called, class_entry of BarClass has num_traits equal to zero".

I think - something is wrong with your PHP configuration or build. try to disable all php extetnsions.

@nikita2206
Copy link
Author

I rechecked PHP on tag 5.4.11, recompiled it, now all works fine, sorry for bothering.

@zendtech
Copy link
Collaborator

Great!

@fotografi
Copy link

No description provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants