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: gc_possible_root #1970

Closed
chrysanthemum opened this issue Oct 13, 2019 · 6 comments
Closed

BUG: gc_possible_root #1970

chrysanthemum opened this issue Oct 13, 2019 · 6 comments
Labels

Comments

@chrysanthemum
Copy link
Contributor

chrysanthemum commented Oct 13, 2019

In PHP 7.1.32, This bug occurs.
In PHP 7.2.22, This bug does not occur.

zephir (0.12.9 ) git revision number: f345c4a

test/globals/server.zep

namespace Test\Globals;

class Server
{
    public function check() {
    	return _SERVER["HTTP_USER_AGENT"];
    }
}

manual.php

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

output:

Assertion failed: ((ref)->gc.u.v.type == 7 || (ref)->gc.u.v.type == 8), function gc_possible_root, file /Users/chrysanth/project/php/php-7.1/Zend/zend_gc.c, line 269.
@chrysanthemum
Copy link
Contributor Author

@dreamsxin Please help

@dreamsxin
Copy link
Contributor

I test branch development, cannot reproduce.

PHP 7.1.32-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 13:28:17) ( NTS )

@sergeyklay
Copy link
Contributor

@dreamsxin Use NTS DEBUG or ZTS DEBUG, not just NTS

@dreamsxin
Copy link
Contributor

Can test change zephir_get_global

if (Z_TYPE_P(gv) == IS_ARRAY) {
				ZVAL_COPY_VALUE(arr, gv);
				zend_string_release(str);
				return SUCCESS;
			}

To

if (Z_TYPE_P(gv) == IS_ARRAY) {
				ZVAL_DUP(arr, gv);
        zend_hash_update(&EG(symbol_table), are, arr);
	zend_string_release(str);
				return SUCCESS;
			}

Link #1961 (comment)

@sergeyklay
Copy link
Contributor

@sergeyklay
Copy link
Contributor

Looks like it is fixed in latest Zephir.

// Zephir code
namespace Bug;

class Globals {

    public function getUserAgent() {
        return _SERVER["HTTP_USER_AGENT"];
    }
}
// manual.php
<?php

use Bug\Globals;

$_SERVER["HTTP_USER_AGENT"] = "Test";

$test = new Globals;
echo $test->getUserAgent() . PHP_EOL;

Output:

Test

Tested PHP versions:

  • 7.1.30 ( ZTS DEBUG )
  • 7.2.20 ( ZTS DEBUG )
  • 7.3.7 ( ZTS DEBUG )

Tested Zephir versions:

  • 0.12.9 (latest release)
  • 0.12.10 (development branch)

If there are bugs, we can follow up in separate issues.

sergeyklay added a commit that referenced this issue Oct 19, 2019
@sergeyklay sergeyklay mentioned this issue Oct 19, 2019
3 tasks
dreamsxin pushed 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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants