Bug #50302 | memory leak in php calling mysql_real_escape_string | ||
---|---|---|---|
Submitted: | 13 Jan 2010 8:51 | Modified: | 15 Jan 2010 8:02 |
Reporter: | Don Cohen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.0.77 | OS: | Linux (2.6.18-128.el5) |
Assigned to: | CPU Architecture: | Any |
[13 Jan 2010 8:51]
Don Cohen
[13 Jan 2010 9:43]
Sveta Smirnova
Thank you for the report. I assume your test script not only contains function definition. Please provide example of PHP code which demonstrates the problem: I want to be sure you don't just collect escaped strings (in this case increasing in memory usage is expected).
[13 Jan 2010 17:49]
Don Cohen
complete test program demonstrating memory leak
Attachment: test.php (application/octet-stream, text), 2.93 KiB.
[13 Jan 2010 17:52]
Don Cohen
The test program is now uploaded. Note that if I were just collecting the strings, the memory would also increase in the version that does not call mysql_real_escape_string.
[13 Jan 2010 17:59]
Don Cohen
While we're at it, here is the output. The input file, of course is much too big to send. I wonder whether the problem might appear only for strings of length more than a certain value, like maybe 1KB. Perhaps these are relatively uncommon as arguments to mysql_real_escape_string and so the bug is not normally observed. You'll see that the program also shows the length of the longest line so far. My original guess was that I was running out of space because one line was very long. $ php -f ./test.php line 1=8584 line 2=9109 line 3=9120 line 7=9258 line 17=9348 line 23=9476 line 29=9617 line 73=9700 line 184=9752 line 242=9766 line 264=9773 line 290=9791 line 320=9798 line 335=9810 line 990=9816 after 1000 memory=10066264 line 1130=9829 PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 5959 bytes) in /root/test.php on line 15
[15 Jan 2010 8:02]
Sveta Smirnova
Thank you for the feedback. > Note that if I were just collecting the strings, the memory would also > increase in the version that does not call mysql_real_escape_string. This is not MySQL bug in this case. This is probably not a bug at all too, but ideally string should be destroyed when you reached last "}" in the loop. Please fill PHP bug report.