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

Crash less and allow more cyclomatic refs #339

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

realFlowControl
Copy link
Collaborator

@realFlowControl realFlowControl commented Mar 10, 2025

This PR fixes the usage of self referencing closures:

  $fibonacci = function ($n) use (&$fibonacci) {
    if ($n == 0) {
      return 0;
    }
    if ($n == 1) {
      return 1;
    }
    return $fibonacci($n - 1) + $fibonacci($n - 2);
  };

This should also fix some segfaults and/or zend_mm_heap corrupted panics.

Granted, the tests I've added (base/071 and base/072) leak memory, but not much and it does not crash anymore 😉

@realFlowControl realFlowControl force-pushed the florian/fixes branch 3 times, most recently from fba96f9 to bbbc3ee Compare March 11, 2025 08:36
@realFlowControl realFlowControl changed the title we will see Crash less and allow more cyclomatic refs Mar 11, 2025
@realFlowControl realFlowControl marked this pull request as ready for review March 11, 2025 20:22
int(55)
int(55)
--XLEAK--
REASON: no cyclic reference collector implemented yet
Copy link

@mvorisek mvorisek Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect all memory to he relased no latter than the 1st GC run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be true "normally", but the memory leaking is not ref counted 😉
The leak is copies I have to create for the closure passed into \parallel\run() to execute it in another thread. So this leak is not referring to user land memory, but extension allocated memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants