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

BUG: zephir_get_global #1961

Closed
chrysanthemum opened this issue Oct 11, 2019 · 12 comments
Labels
bug

Comments

@chrysanthemum
Copy link
Contributor

@chrysanthemum chrysanthemum commented Oct 11, 2019

Close all extensions compiled by zephir, including the phaclon extension. Leave only the test extension.

test/globals/server.zep

namespace Test\Globals;

class Server
{
    public function f1() -> void
    {
        echo _SERVER["PHP_SELF"];
        this->f2();
        echo _SERVER["PHP_SELF"];
    }
    
    public function f2() -> void
    {
        echo _SERVER["SCRIPT_NAME"];
    }
}

manual.php

$t = new Test\Globals\Server();
$t->f1();

output:

/php-src/php-7.2/Zend/zend_hash.c(1968) : ht=0x107e65720 is already destroyed
Assertion failed: (0), function _zend_is_inconsistent, file /php-src/php-7.2/Zend/zend_hash.c, line 64.
@chrysanthemum

This comment has been minimized.

Copy link
Contributor Author

@chrysanthemum chrysanthemum commented Oct 11, 2019

@dreamsxin Could you fix this BUG? I'm afraid I'll make a mistake.

@sergeyklay sergeyklay added the bug label Oct 11, 2019
@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 11, 2019

@chrysanthemum Could you please provide exact PHP version and used Zephir version/commit

@chrysanthemum

This comment has been minimized.

Copy link
Contributor Author

@chrysanthemum chrysanthemum commented Oct 11, 2019

php:

PHP 7.2.22 (cli) (built: Sep 21 2019 13:19:31) ( NTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
    with Zend OPcache v7.2.22, Copyright (c) 1999-2018, by Zend Technologies

zephir:

Zephir 0.12.9
git revision number: 4155edf8824ee64a4255be929c48ee108528e8d5

operating system:

macOS Mojave 10.14.6
@chrysanthemum

This comment has been minimized.

Copy link
Contributor Author

@chrysanthemum chrysanthemum commented Oct 11, 2019

@dreamsxin I got it wrong. There's no bug :)

@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 11, 2019

@chrysanthemum Should we close this one?

@chrysanthemum

This comment has been minimized.

Copy link
Contributor Author

@chrysanthemum chrysanthemum commented Oct 11, 2019

@sergeyklay

Oddly enough, this problem occurred when I closed all the zephir compiled extensions, leaving only the test extension.

If I open the phaclon extension, the bug does not appear.

Do you have this bug? (Close all zephir compiled extensions, leaving only the test extension.)

@chrysanthemum chrysanthemum reopened this Oct 11, 2019
@chrysanthemum

This comment has been minimized.

Copy link
Contributor Author

@chrysanthemum chrysanthemum commented Oct 11, 2019

This strange bug does exist.
@dreamsxin

@dreamsxin

This comment has been minimized.

Copy link
Member

@dreamsxin dreamsxin commented Oct 12, 2019

@dreamsxin dreamsxin referenced this issue Oct 12, 2019
0 of 3 tasks complete
@sergeyklay sergeyklay closed this Oct 12, 2019
@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 12, 2019

Fixed in the development branch. Feel free to open a new issue if the problem appears again. Thank you for bug report.

@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 13, 2019

I'll open this one because changes proposed in #1965 broke our tests.

For more see:

@sergeyklay sergeyklay reopened this Oct 13, 2019
@dreamsxin

This comment has been minimized.

Copy link
Member

@dreamsxin dreamsxin commented Oct 14, 2019

@sergeyklay

public function f1() -> void
{
	echo _SERVER["PHP_SELF"];
	this->f2(); // In zephir_get_global use ZVAL_DUP will separation
	echo _SERVER["PHP_SELF"];
}

generate c code:

ZEPHIR_MM_GROW();
zephir_get_global(&_SERVER, SL("_SERVER")); // separation

zephir_array_fetch_string(&_0, &_SERVER, SL("PHP_SELF"), ...);
zend_print_zval(&_0, 0);

ZEPHIR_CALL_METHOD(NULL, this_ptr, "f2", NULL, 0); // separation
zephir_check_call_status();

zephir_array_fetch_string(&_1, &_SERVER, SL("PHP_SELF"), ...); // <-- After separation, the variables here fail. is already destroyed
zend_print_zval(&_1, 0);
ZEPHIR_MM_RESTORE();
@dreamsxin

This comment has been minimized.

Copy link
Member

@dreamsxin dreamsxin commented Oct 14, 2019

@sergeyklay So we need to get global every time.

ZEPHIR_MM_GROW();
zephir_get_global(&_SERVER, SL("_SERVER"));

zephir_array_fetch_string(&_0, &_SERVER, SL("PHP_SELF"), ...);
zend_print_zval(&_0, 0);

ZEPHIR_CALL_METHOD(NULL, this_ptr, "f2", NULL, 0);
zephir_check_call_status();

zephir_get_global(&_SERVER, SL("_SERVER")); // <-- Get global again
zephir_array_fetch_string(&_1, &_SERVER, SL("PHP_SELF"), ...);
zend_print_zval(&_1, 0);
ZEPHIR_MM_RESTORE();
@dreamsxin dreamsxin referenced this issue Oct 19, 2019
sergeyklay added a commit that referenced this issue Oct 19, 2019
Re fix #1961
sergeyklay added a commit that referenced this issue Oct 19, 2019
See: #1961, #1970
@sergeyklay sergeyklay referenced this issue Oct 19, 2019
3 of 3 tasks complete
dreamsxin added a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
dreamsxin added a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.