bpo-33630: Fix memory leak in old versions of glicb for posix_spawn.#7685
Conversation
posix_spawn.posix_spawn.
|
This is complementing #7663. @serhiy-storchaka I have addressed your feedback in 07e1245 |
|
I can confirm again that this fixes the buildbot problems. Tested on the buildbot itself: |
|
It seems that the problem covered by #7663 (the race in the test) disappears once this is fixed. As is a race condition I am not sure, but running 3 test suites in parallel that executes |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you @pablogsal for your responsibility!
LGTM in general, added just few stylistic comments.
| goto fail; | ||
| } | ||
| int error = PyList_Append(temp_buffer, path); | ||
| if (error) { |
There was a problem hiding this comment.
Seems the error variable is used only here. In this case it would be better to inline it.
There was a problem hiding this comment.
Done in commit 80918db
| if (file_actions != Py_None) { | ||
| if (parse_file_actions(file_actions, &file_actions_buf)) { | ||
|
|
||
| /* There is a bug in old versions of glibc that makes some of the |
There was a problem hiding this comment.
There are two large comments about this issue which are not duplicates of one other. It would be better to merge them.
There was a problem hiding this comment.
Done in commit 80918db
| * https://sourceware.org/bugzilla/show_bug.cgi?id=17048 for more info. */ | ||
|
|
||
| temp_buffer = PyList_New(0); | ||
|
|
There was a problem hiding this comment.
IMHO it would look clearer if remove some of empty lines (or even all new empty lines).
There was a problem hiding this comment.
Done in commit 80918db.
| * buffers. The use of `temp_buffer` here is a workaround that keeps the | ||
| * python objects that own the buffers alive until posix_spawn gets called. | ||
| * posix_spawn_file_actions_addopen copies the value of **path** except for | ||
| * some old * versions of * glibc (<2.20). The usage of temp_buffer is |
There was a problem hiding this comment.
What all these stars mean?
There was a problem hiding this comment.
Sorry, that was an error after wrapping the lines. Fixed in 54de1e2
There was a problem hiding this comment.
I am rewriting a bit this paragraph.
|
@serhiy-storchaka I have rewritten a bit the comment in 0e3348e to make it more clear. |
| /* There is a bug in old versions of glibc that makes some of the | ||
| * helper functions for manipulating file actions not copy the provided | ||
| * buffers. The use of `temp_buffer` here is a workaround that keeps the | ||
| * buffers. The problem is that posix_spawn_file_actions_addopen copies |
There was a problem hiding this comment.
Actually the problem is not that posix_spawn_file_actions_addopen copies the value of path, but that it isn't copies in on glibc <2.20.
Comments are plain text, no need to use the Markdown mark up (**path**, `temp_buffer`).
There was a problem hiding this comment.
Actually the problem is not that posix_spawn_file_actions_addopen copies the value >of path, but that it isn't copies in on glibc <2.20.
Sorry, bad redaction on my part. I was trying to express that addopen copies it except for older versions of glibc and the fact that these old versions don't copy it is the problem.
Fixed in c74b988
| goto fail; | ||
| } | ||
| if (PyList_Append(temp_buffer, path)) { | ||
| goto fail; |
There was a problem hiding this comment.
Hmm, we keep a reference to path and need to decrease here?
https://bugs.python.org/issue33630