Invalid Pointer on end initialize method on model

Hi,

I upgrade my website from Phlacon 3 to Phalcon 4.

On my model, the program crash at the end of the method "initialize" Code :

public function initialize()
    {
        $this->setSource('nbConn');
        if (!$this->getDI()->get('db')->tableExists('nbConn'))
        {
            $logger = $this->getDI()->get('logger');
            $logger->error("La table nbConn n'éxiste pas");
            throw new \Phalcon\Mvc\Dispatcher\Exception();
        }
    }// Here the error....

Error : free(): invalid pointer

Can someone help me ?

What line is causing the error? Try commenting them out until the error goes away.



3.9k
edited Aug '20

When exit the method.... so the last line with "}"

I saw that with the debugger, so perhaps it's not this line, but all the code before work and no code after this.

The only bug reports I can find with that wording are for errors in the PHP engine (ie C++) not PHP code. So it might not be something you can fix. Still - comment out lines until the error goes away. That will help you narrow down what is actually causing the problem.



3.9k
edited Aug '20

I comment all the code in the method and i have the same crash... I know it's not a PHP bug, mais it's Phalcon ! I have this bug on any models...., Its' a Phalcon bug....

Good framework... How can i fix my problem ? the website is on production and i need to upgrade it...

If this is production, I would downgrade back to 3, and do the upgrade in testing/development.

So even with no lines of code in the initialize() method, the error is still triggered at the end of the method?



3.9k

In prod it's version 3. Of course, I upgrade in testing.

With no code, it's same. If i comment the code which call models, my website works. It's only here. With or without code, the same error. Should be an error on Phalcon code with a bad configuration ? Or a bad version of PHP ? I installed with package apt.



3.9k

Hi,

I have the bug in all models, with or without initialize method, with or without code inside initialize method....

The error report text certainly does sound like it's a problem with Phalcon. If this is happening with all models, it's not your model code - it's something else. It may be Phalcon, or it may be something at a lower level in your app - like something in your bootstrap.

While it's a pain in the butt to do, I would strip everything back until you don't get the error. Have a controller action that doesn't use models, remove any custom services, etc. At some point you'll get a page load without an error. Then, start adding stuff back until you get the error again.



3.9k

My website works well when i remove all models (I use WebService for the data, so i have only 3 models for the connexion, forgot password and signin). It's when i call model. Always the same error.

I tried with empty model (without code, just call the model), same error....

Error just with this code : class Test extends model { }

$test = new Test();

edited Sep '20

Yes my site worked well with the same models too UPSers



3.9k

So, no solution ?

The only reference to free() I can find in PHP-land is related to database result sets. All models in Phalcon are mapped to a database table. Without using models, are you able to run a database query with the db service?

In a controller, you can do something like:

$result = $this->db->query('SELECT * FROM `someTable`')->fetchAll();


3.9k

Yes, it's works....

And all your models extend \Phalcon\Mvc\Model?



3.9k

Yes, all.

I'd make a bug report on Phalcon's Github. This may be a Phalcon bug.



3.9k

Thanks you. Can I have the link for follow this bug ?

Hello, Could you check that your PHP version is at least 7.2?



3.9k

Hello,

Php version is 7.4.9

Thanks you. Can I have the link for follow this bug ?

Sorry, I think there is a language barrier. I didn't file a bug report - I'm recommending you file a bug report.



3.9k

Thanks you. Can I have the link for follow this bug ?

Sorry, I think there is a language barrier. I didn't file a bug report - I'm recommending you file a bug report.

Oh Ok! My english is bad.

Thanks you. Can I have the link for follow this bug ?

Sorry, I think there is a language barrier. I didn't file a bug report - I'm recommending you file a bug report.

Oh Ok! My english is bad.

No problem. Your english is quite good, I was just using poor sentence structure (which English is full of).