-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
Access to undeclared static property #1530
Comments
Does php7 do not need TSRMLS_CC |
As long as the load is high, will appear "Access to undeclared static property"。 |
Add that this happens only on php apache module, on cli or fpm it works fine and without issues. |
@sjinks Could you please take a look |
@sjinks It's rather important that you take a look at this bug as soon as possible, because it prevents usage of thread-safe extension on any platform, not only windows. So, it's no longer possible to use phalcon with pthreads and similar stuff which actually requires thread safety. |
I got this error on Phalcon 3.2.0 today. |
@php318 Could you change your code to: namespace XqKeji;
class Di
{
private static _default;
public static function getInstance()
{
- var di
- let di = self::_default;
- if !di {
+ if typeof self::_default !== "object" {
- let di = new self();
- let self::_default = di;
+ let self::_default = new self();
}
return self::_default;
}
} and test it |
@sergeyklay i saw you are doing some tests with this, are you sure you are doing it on TS php? Beacause as i remember this is main issue, but not sure. |
@sergeyklay |
Hey guys, what was the outcome to this bug? I'm encountering the same issue on Windows and Apache 2.4 running PHP 7.1.1 and Phalcon 3.2.4 |
@mattratcliffe86 Use nginx + php-fpm instead of Apache. There are some issues with thread safety of the extension. |
@hakimio Thanks for that. So this is specifically affecting the thread safe extension for Apache, just on Windows or is it Linux too? |
@mattratcliffe86 It's effecting both windows and linux thread-safe extensions. |
I have the same problem:
It occurs especially when there are many requests in the same time or fast one by one in row. |
@Pilsenerek |
I'm going to solve this issue so I need code to reproduce guys. Could someone provide a worked (badly) example? |
@sergeyklay It's rather easy to reproduce the issue. You just need to run phalcon Thread-Safe extension with Apache on Windows (some people reported the issue on Linux as well but I've never tried running Phalcon TS on Linux personally) and then just make a large number of parallel requests (shouldn't need more than a 100) to a single end-point which does some simulated work ("usleep(100000)" should work just fine). |
I need to locate problem. So it is too complex to use full framework to debug this. Actually I need an example as small as possible |
Maybe then create a simple Zephir extension, compile it with TS and use pthreads to check if it is actually thread safe? |
Quick and dirty way to reproduce the error... I've created a controller 'reload' which just reloads the page a given number of times and increments the value in the url segment by 1 each time. I'm redirecting, which is what I did when I first encountered the problem. Same thing occurs when you use $response->redirect() (\Phalcon\Http\Response) or the native header() function in PHP. PHP Fatal error: Uncaught Error: Access to undeclared static property Phalcon\Di::$_default in index.php on line 10 Line 10 happens to be $di = new FactoryDefault(); |
I still have this error (Phalcon 3.3.2 with PHP7.2) when the app performs two ajax requests at the same time. If I perform the first ajax call and 500ms later I call the second ajax, it works. |
I can't reproduce,
ab -c 20 -n 200 http://localhost:8181/ Another test code: namespace Mytest;
class Di
{
private static _default;
public static function getInstance()
{
var di;
let di = self::_default;
if !di {
let di = new self();
let self::_default = di;
}
return self::_default;
}
}
class App
{
public function __construct()
{
var di;
let di = Di::getInstance();
}
} Phalcon v3.4.0
|
@dreamsxin You have to use Zephir 0.10.x for Phalcon 3.x and Zephir 0.11.x for Phalcon 4.x. This is why you get "PHP Fatal error" for Phalcon v3.4.0 using Zephir 0.11.x Did you use Thread-Safe extension with Apache ? It is important here |
@sergeyklay I don't have an apache environment. |
@dreamsxin Is there any chance that you will be able to use a Docker or any VM? |
@sergeyklay I'm not sure that under Linux, libapache-mod-php uses thread safe, and my computer is too old. It would be great if you can test and get core dump. |
@dreamsxin you should be able to reproduce the issue with TS php-cli as well. |
@hakimio Can't reproduce, Previously tested in CLI Ubuntu 16.04 |
@dreamsxin I managed to produce a dump. That's a pretty version produced by If you need the |
I will feedback |
@CameronHall Unfortunately, my computer is not Windows.
I want to admire that the document is too big. |
No worries. If you're okay with the HTML files from DebugDiag, I can generate them for the other dumps I send to you via email. |
I sent @dreamsxin the dumps. I also sent him this stack trace.
|
I can't see the problem from this information. If I can reproduce it from linux, I can write different code to test it. |
@dreamsxin Have you tried to run Phalcon CLI TS with pthreads / multiple threads? |
@hakimio I've just tested this myself on PHP 7.3 CLI TS on Apline Linux and can confirm (not with pthreads) that the issue is not reproducible. If you're interested in how I tested let me know and I'll create a repo. Right now, I'm creating a Windows 10 VM on Azure for @dreamsxin to play with. |
@CameronHall it has to be multi-threaded app, because the issue is with thread-safety. |
That would make sense. Apache would typically do that for us... does
someone have a sample multi-threaded app?
…On Wed, 20 Mar 2019 at 12:29 am, Tomas Rimkus ***@***.***> wrote:
@CameronHall <https://github.com/CameronHall> it has to be multi-threaded
app, because the issue is with thread-safety.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1530 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG-ifdzc-HPvHBrecE0EwYOBIsn88vBpks5vYOYggaJpZM4NNno6>
.
|
@dreamsxin I sent you an email yesterday with the details to access the VM. |
@CameronHall I will try. |
@dreamsxin I believe the issue may haver to do with the zephir_deinitialize_memory method. Though I don't know enough about the PHP Internals to be sure. Do you have any ideas? |
Maybe double free the zval. |
Can't reproduce
Zephir code: namespace Test;
class app
{
public function __construct()
{
var di;
let di = Di::getInstance();
}
} namespace Test;
class Di
{
private static _default;
public static function getInstance()
{
var di;
let di = self::_default;
if !di {
let di = new self();
let self::_default = di;
}
return self::_default;
}
} |
@dreamsxin didn't @CameronHall already provide you with a VM you can use for testing? |
I just had this problem with Phalcon 3.4, use Zephir/development regenerate code,the problem solving. git clone https://github.com/dreamsxin/zephir.git
git fetch origin
git checkout origin/phalcon_3.4 -f
cd cphalcon-3.4
../zephir/zephir fullclean
../zephir/zephir generate
cd ext/
make -j4 && make install test.php <?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$di = new Phalcon\DI\FactoryDefault;
echo "ok".PHP_EOL; ab -v2 -n 1000 -c 50 http://localhost/test.php |
Closing, this is fixed. If there are bugs, we can follow up in separate issues. |
When ajax request more than 3 times, there will be "Access to undeclared static property"
E.g
Test:
in window php7.0 ts
The text was updated successfully, but these errors were encountered: