You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
well there is an ZendMM out of memory triggered with the line length, so the iconv flows do not get freed, that is expected. Either we put len checks but then it defeats the usefulness of safe emalloc here or leave it as is. cc @nielsdos thoughts ?
Fine by me.
That would "fix" this issue, but would not fix the general problem and I'm sure you could still trigger the same issue via other means. For example in this code, if one of the smart_str operations causes a bailout you have the exact same problem.
The core problem is that iconv uses the system allocator, so on bailout we don't free the data. This is a general problem in many extensions.
Reacted by Christoph M. Becker and Gina Peter Banyard
Activity
devnexen commentedon Jan 8, 2025
well there is an ZendMM out of memory triggered with the line length, so the iconv flows do not get freed, that is expected. Either we put len checks but then it defeats the usefulness of safe emalloc here or leave it as is. cc @nielsdos thoughts ?
cmb69 commentedon Jan 8, 2025
php-src/ext/iconv/iconv.c
Line 965 in cee64ed
We could move up that allocation prior to the first
iconv_open()call.devnexen commentedon Jan 8, 2025
Yes I was starting to think it too but you did it way faster than me, feel free to open a PR :)
ndossche commentedon Jan 8, 2025
Fine by me.
That would "fix" this issue, but would not fix the general problem and I'm sure you could still trigger the same issue via other means. For example in this code, if one of the smart_str operations causes a bailout you have the exact same problem.
The core problem is that iconv uses the system allocator, so on bailout we don't free the data. This is a general problem in many extensions.
cmb69 commentedon Jan 23, 2025
Hmm, given that this has been found by fuzzing, maybe we should add
iconv_open(and maybe some other functions) to lsan-suppressions.txt?ndossche commentedon Jan 23, 2025
That might hide real leaks too. I think it's more important to keep reporting such leaks than risking false negatives.
Fix phpGH-17399: iconv memory leak with large line-length
Fix phpGH-17399: iconv memory leak on bailout
Merge branch 'PHP-8.4' into PHP-8.5
Merge branch 'PHP-8.5'
Fix GH-17399: iconv memory leak on bailout