#47 Class destructor is not called automatically

Closed
opened 1 year ago by belliash · 7 comments
belliash commented 1 year ago
Owner

AerScript Information

  • Aer Version (or commit ref): d4992ff4ba
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

Class destructor is not called automatically, see example code:

<?php
class X {
    function __construct() {
            echo 'Constructor';
    }
    function __destruct() {
            echo 'Destructor';
    }
}
$x = new X();
?>

Above code gives the same result in PH7. This bug is derived from upstream project.

Expected results

'ConstructorDestructor' should appear.

Current results

'Constructor' appears only, what means that destructor is not called.

<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # AerScript Information - Aer Version (or commit ref): d4992ff4ba - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description Class destructor is not called automatically, see example code: <?php class X { function __construct() { echo 'Constructor'; } function __destruct() { echo 'Destructor'; } } $x = new X(); ?> Above code gives the same result in PH7. This bug is derived from upstream project. # Expected results 'ConstructorDestructor' should appear. # Current results 'Constructor' appears only, what means that destructor is not called.
belliash added the
bug
label 1 year ago
belliash commented 1 year ago
Poster
Owner

Additionally, we have broken the unset() function, as it is calling the __destruct() method in PH7.

Additionally, we have broken the unset() function, as it is calling the __destruct() method in PH7.
belliash commented 1 year ago
Poster
Owner

unset() builtin function seems broken partially since bd4d146d0a. Looks like it was never working for variables defined with a specified data type. If no data type is specified then unset() is still working.

Seems, there is some difference between:

$x = new Obj();

and

object $x = new Obj();
unset() builtin function seems broken partially since bd4d146d0a. Looks like it was never working for variables defined with a specified data type. If no data type is specified then unset() is still working. Seems, there is some difference between: $x = new Obj(); and object $x = new Obj();
belliash commented 1 year ago
Poster
Owner
object $x;
$x = new Obj();

Above version is not affected.

object $x; $x = new Obj(); Above version is not affected.
belliash commented 1 year ago
Poster
Owner

This is related to missed OP_POP call when assigning a value during variable declaration.

This is related to missed OP_POP call when assigning a value during variable declaration.
belliash referenced this issue from a commit 1 year ago
belliash commented 1 year ago
Poster
Owner

Fixed everything, what got broken within 'typehinting' branch.
Static variables (both in methods/closure and class attributes) were never destroyed properly in PH7. Fixing this bug will lead to:

  • fixing a garbage collector and freeing more memory,
  • automatically calling a destructor if available (when static variable was an object)
Fixed everything, what got broken within 'typehinting' branch. Static variables (both in methods/closure and class attributes) were never destroyed properly in PH7. Fixing this bug will lead to: * fixing a garbage collector and freeing more memory, * automatically calling a destructor if available (when static variable was an object)
belliash commented 1 year ago
Poster
Owner

Segmentation fault fixed in 407bcf5a29.

Segmentation fault fixed in 407bcf5a29.
belliash commented 1 year ago
Poster
Owner

Fixed in 171456beb4.
Test extended in 4afcbc0815 confirms, it is working.

Fixed in 171456beb4. Test extended in 4afcbc0815 confirms, it is working.
belliash closed this issue 1 year ago
belliash self-assigned this 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.