Skip to content

bpo-33630: Fix memory leak in old versions of glicb for posix_spawn.#7685

Merged
serhiy-storchaka merged 9 commits into
python:masterfrom
pablogsal:bpo33630-2
Jun 19, 2018
Merged

bpo-33630: Fix memory leak in old versions of glicb for posix_spawn.#7685
serhiy-storchaka merged 9 commits into
python:masterfrom
pablogsal:bpo33630-2

Conversation

@pablogsal

@pablogsal pablogsal commented Jun 13, 2018

Copy link
Copy Markdown
Member

@pablogsal pablogsal changed the title bpo-33630: Fix memory leak in older versions of glicb for posix_spawn. bpo-33630: Fix memory leak in old versions of glicb for posix_spawn. Jun 13, 2018
@pablogsal

pablogsal commented Jun 13, 2018

Copy link
Copy Markdown
Member Author

This is complementing #7663. @serhiy-storchaka I have addressed your feedback in 07e1245

@pablogsal

Copy link
Copy Markdown
Member Author

I can confirm again that this fixes the buildbot problems. Tested on the buildbot itself:

[pablogsal@gcc1-power7 cpython]$ git rev-parse HEAD
6db5f32e0236deba37d7799801dd605c40ecd025


[pablogsal@gcc1-power7 cpython]$ uname -a
Linux gcc1-power7.osuosl.org 3.10.0-514.26.2.el7.ppc64 #1 SMP Mon Jul 10 02:26:53 GMT 2017 ppc64 ppc64 ppc64 GNU/Linux

[pablogsal@gcc1-power7 cpython]$ ./configure --with-pydebug && make -j
....

[pablogsal@gcc1-power7 cpython]$ ./python -m unittest test.test_posix
ss....s....................ss................ss............s...s.....................................
----------------------------------------------------------------------
Ran 101 tests in 1.916s

OK (skipped=9)
[pablogsal@gcc1-power7 cpython]$ ./python -m test test_posix -R 3:3
Run tests sequentially
0:00:00 load avg: 7.20 [1/1] test_posix
beginning 6 repetitions
123456
......

== Tests result: SUCCESS ==

1 test OK.

Total duration: 6 sec
Tests result: SUCCESS

@pablogsal

Copy link
Copy Markdown
Member Author

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 test_posix 200 times does not raise any problem on the buildbot.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pablogsal for your responsibility!

LGTM in general, added just few stylistic comments.

Comment thread Modules/posixmodule.c Outdated
goto fail;
}
int error = PyList_Append(temp_buffer, path);
if (error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the error variable is used only here. In this case it would be better to inline it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 80918db

Comment thread Modules/posixmodule.c
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two large comments about this issue which are not duplicates of one other. It would be better to merge them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 80918db

Comment thread Modules/posixmodule.c Outdated
* https://sourceware.org/bugzilla/show_bug.cgi?id=17048 for more info. */

temp_buffer = PyList_New(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it would look clearer if remove some of empty lines (or even all new empty lines).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 80918db.

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error skip news labels Jun 15, 2018
Comment thread Modules/posixmodule.c Outdated
* 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What all these stars mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was an error after wrapping the lines. Fixed in 54de1e2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am rewriting a bit this paragraph.

@pablogsal

pablogsal commented Jun 15, 2018

Copy link
Copy Markdown
Member Author

@serhiy-storchaka I have rewritten a bit the comment in 0e3348e to make it more clear.

Comment thread Modules/posixmodule.c Outdated
/* 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`).

@pablogsal pablogsal Jun 15, 2018

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread Modules/posixmodule.c
goto fail;
}
if (PyList_Append(temp_buffer, path)) {
goto fail;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we keep a reference to path and need to decrease here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0ee9f25

@serhiy-storchaka serhiy-storchaka merged commit cb97073 into python:master Jun 19, 2018
@pablogsal pablogsal deleted the bpo33630-2 branch May 19, 2021 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants