-
Notifications
You must be signed in to change notification settings - Fork 602
Fix memory leak in Data::Dumper::Dumper #17673
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
Conversation
How could one observe this leakage? |
When Dumper was called without arguments and in list context it leaked the preallocated retval scalar: perl -MData::Dumper -e '() = Dumper while 1'
584e557 to
92b62a2
Compare
|
I added the example to the commit message: |
|
All the smoke test failures seem to be because of Data::Dumper's version staying the same despite changes to the source. |
Corrected and pushed for smoking to branch smoke-me/jkeenan/niner/ghpr-17673-dumper-leak. |
|
I think the fix is correct but surprising. I think it would be clearer to just always create retval as a mortal. That way the right thing happens whether it is pushed or not. Or am I missing something? |
I felt horrified reading that code. There're two places where it's created, so both should be updated. And there're at least two more problems with this patch's approach:
|
| croak("Call to new() method failed to return HASH ref"); | ||
| if (gimme != G_ARRAY) | ||
| XPUSHs(sv_2mortal(retval)); | ||
| else if (imax < 0) /* Would leak if there was nothing to dump */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is formatted incorrectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a tabs vs spaces, the if (gimme... is indented with a tab, while the else is just spaces.
|
Given the leak is not critical, I assume it should not go into 5.32 at this point? |
Since 5.33.0 has been released, this ticket is now eligible for further work. Can the contributors take another look? Thank you very much. |
|
This was fixed by 4146316 |
When Dumper was called without arguments and in list context it leaked the
preallocated retval scalar.