-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fixed bug #61828 Memleak when calling Directory(Recursive)Iterator/Spl(T... #71
Conversation
Hi: A object is an instance, double construct it is essentially wrong. thanks On Mon, Apr 30, 2012 at 11:42 AM, reeze
Laruence Xinchen Hui |
@php-pulls $instance->__construct(); so does other magic methods, should we forbid user-land magic method calling? |
On Mon, Apr 30, 2012 at 12:55 PM, reeze
thanks
Laruence Xinchen Hui |
It seems that constructor did create new instance when calling __constuct(); __construct(".."); var_dump($x === $y); // true |
On Mon, Apr 30, 2012 at 1:29 PM, reeze
thanks
Laruence Xinchen Hui |
You should not call __construct() directly, you should use new for that. |
It more likely state changing but not feature changing eg: $x->setProp($value) "you didn't understand my point, I mean, a object should be a @smalyshev yes it's wrong to do that, but users can do that way, so a simple check would be fine to prevent memleak. |
On Mon, Apr 30, 2012 at 2:08 PM, reeze
what I said is your fix is not in the right way, prevent wrong usage thanks
Laruence Xinchen Hui |
I agree with @reeze that this should be fixed. PHP does not prevent anyone from explicitly calling the constructor after the object was already created. Sure, you probably should not do it, but doing it should not leave you with a memleak. |
On Mon, Apr 30, 2012 at 4:54 PM, nikic
sure, if we can fix it in a proper way, of course we should fix it. but I really doubt it by allow people re-construct a object. instead, thanks
Laruence Xinchen Hui |
In user land script. he can do some work like db connection initialization in __constructor. But in SPL, SPL should responsible for it and free the resource . |
On Mon, Apr 30, 2012 at 5:14 PM, reeze
but please, except the fixing way, let's focus on your fix, as I what I said is, plz don't fix something by rush. like your fix, I have to say it's wrong, did you test with it? like: __construct(1); } catch (Exception $e) { } try { $a->__construct(1); } catch (Exception $e) { } will cause double free.. thanks > --- > > Reply to this email directly or view it on GitHub: > https://github.com//pull/71#issuecomment-5414042 > > ## > > Git Pull Requests Mailing List (https://github.com/php) > To unsubscribe, visit: http://www.php.net/unsub.php ## Laruence Xinchen Hui http://www.laruence.com/ |
oh, thanks for point out this edge case reeze | simpie.com 在 2012年4月30日星期一,下午5:51,Account for PHP Pull Requests 写道:
|
On Mon, Apr 30, 2012 at 6:13 PM, reeze
thanks
Laruence Xinchen Hui |
you are right ,more work needed to get this fixed Reeze On 2012年4月30日Monday at 18:37, Account for PHP Pull Requests wrote:
|
I've tested all PHP classes with direct constructor calls (using my fuzzer) and just got those memleaks from some SPL classes at the moment. So I guess it's ok to fix that case, just like I did for other class. |
Hi, this patch makes sense. Internal classes should be as robust as possible, they should not rely on "best-usage" principles from userland code. Best, |
thanks. this patch need to be improved to handle certain cases provided by laruence, I will update it later. |
…l(Temp)FileObject ctor twice
Hi, guys: Thanks. |
…erator/Spl(Temp)FileObject
Hi,
This memory leak is the same as felipe ever fixed one:
commit af2fc62
Author: Felipe Pena felipe@php.net
Date: Sun Mar 11 15:42:57 2012 +0000
The bug affect those SPL classes:
Hi, @felipensp will you take a look at this pull request?
Thank you.