Skip to content
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

bpo-34563: Fix for invalid assert on big output of multiprocessing.Process #9027

Merged
merged 10 commits into from Sep 4, 2018

Conversation

ahcub
Copy link
Contributor

@ahcub ahcub commented Sep 1, 2018

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

I signed the CLA, can someone check what is the issue with it?

@Mariatta
Copy link
Member

Mariatta commented Sep 1, 2018

Hi, it can take at least one business day for it to be reflected on our system. Thanks.

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

ah, didn't know that, thank you!

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

I get an error on Travis CI Build but I'm not sure how to fix it. It goes as the following.

Error in file "./Modules/_winapi.c" on line 1365:
Checksum mismatch!
Expected: 492029ca98161d84
Computed: d3d5b44a8201b944
Suggested fix: remove all generated code including the end marker,
or use the '-f' option.

but I don't have any generated code
Any advice?

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

oh, maybe I do have changes in the generated code, hm, probably I need to change the clinic input instead of the function header

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

hm, now I'm getting an error that generated files are not up to date

$ # Check for changes in regenerated files
  if ! test -z "$changes"
  then
    echo "Generated files not up to date"
    echo "$changes"
    exit 1
  fi
  
Generated files not up to date
 M Modules/_winapi.c
 M Modules/clinic/_winapi.c.h

I'm not sure what I did wrong this time
Any advice?

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

ok, looks like there was a requirement for a test in the change, I added a python test case for this issue

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

seems like non-python test is required here, hm

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

ok, I understand what is required but I don't understand how can I write a test for the changes I've made
I tried to search for examples on pythoncore C tests, but I cannot see any, and it should be a generated test also if I read the travis.yml correctly as it must be in git status --porcelain cmd output
is there any guide or example I can take inspiration from?

latest commits into _winapi.c don't contain any C test files that would look like the ones I need...

@ahcub
Copy link
Contributor Author

ahcub commented Sep 1, 2018

@vstinner sorry for tagging, but can you help?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Honestly, I'm not sure that it's worth it to write an unit test allocating 2 GiB of memory and writing 2 GiB of output into a stdout pipe. I propose to remove the test.

@@ -0,0 +1 @@
Fix for invalid assert on big output of multiprocessing.Process
Copy link
Member

Choose a reason for hiding this comment

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

You should mention _winapi.PeekNamedPipe() and _winapi.ReadFile(). Maybe:

Fix _winapi.PeekNamedPipe() and _winapi.ReadFile() for read larger than INT_MAX (usually 2^31-1).

I'm not sure that it's worth it to mention multiprocessing in the NEWS entry.

Copy link
Member

Choose a reason for hiding this comment

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

_winapi is a private module. _winapi.PeekNamedPipe() and _winapi.ReadFile() are used only in multiprocessing.connection. It is an implementation detail. The end user uses multiprocessing.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so maybe mention both: _winapi and multiprocessing.Connection fixes. Example:

On Windows, fix multiprocessing.Connection for very large read: fix _winapi.PeekNamedPipe() and _winapi.ReadFile() for read larger than INT_MAX (usually 2^31-1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with serhiy-storchaka



class TestMultiprocessingWithBigOutput(unittest.TestCase):
@unittest.skip("skipping test for manual use only. Highly demanding on RAM and time consuming")
Copy link
Member

Choose a reason for hiding this comment

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

Use the test.support.bigmemtest decorator.

@@ -0,0 +1 @@
Fix for invalid assert on big output of multiprocessing.Process
Copy link
Member

Choose a reason for hiding this comment

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

_winapi is a private module. _winapi.PeekNamedPipe() and _winapi.ReadFile() are used only in multiprocessing.connection. It is an implementation detail. The end user uses multiprocessing.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

Here are a couple comments. Also, did you make sure the test also passes on Unix, or should someone else test it for you?

@@ -0,0 +1,25 @@
import unittest
Copy link
Member

Choose a reason for hiding this comment

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

All multiprocessing tests should go into _test_multiprocessing.py, so that they get executed under the different execution contexts ("fork", "forkserver", "spawn").



def func():
return 'test' * (10 ** 9)
Copy link
Member

Choose a reason for hiding this comment

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

Please use a binary string (b"test"), and add a comment stating the expected memory consumption.

}
}

/*[clinic input]
_winapi.ReadFile

handle: HANDLE
size: int
size: DWORD
Copy link
Member

Choose a reason for hiding this comment

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

Hmm... how come you changed this and the generated code didn't change? Did you run make clinic to update all files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, sorry, I was not aware of the process and I thought that the files are regenerated on the build somehow, I committed the changes to the generated section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the checks passed this time it seems, can you recheck if all good @pitrou?

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ahcub
Copy link
Contributor Author

ahcub commented Sep 3, 2018

I removed the test because I agree with @vstinner comment about it, it is redundant

@pitrou
Copy link
Member

pitrou commented Sep 3, 2018

Thanks @ahcub! This looks good to me now.

@pitrou
Copy link
Member

pitrou commented Sep 3, 2018

Waiting for the CLA to be validated now.

@vstinner
Copy link
Member

vstinner commented Sep 3, 2018

FYI @ahcub bugs.python.org account is: https://bugs.python.org/user29366 and I don't see "Contributor Form Received" checked yet. We have to wait for the manual CLA process.

@ahcub
Copy link
Contributor Author

ahcub commented Sep 3, 2018

Thanks for your prompt review and guidance, guys.
I hope they will process my CLA soon

@ahcub
Copy link
Contributor Author

ahcub commented Sep 4, 2018

The CLA is accepted, is it possible to merge it in today? @pitrou @vstinner

@vstinner vstinner merged commit 266f490 into python:master Sep 4, 2018
@vstinner
Copy link
Member

vstinner commented Sep 4, 2018

Done ;-)

@miss-islington
Copy link
Contributor

Thanks @ahcub for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @ahcub for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @ahcub and @vstinner, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 266f4904a222a784080e29aad0916849e507515d 3.6

@bedevere-bot
Copy link

GH-9064 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 4, 2018
…ocess (pythonGH-9027)

Fix for invalid assert on big output of multiprocessing.Process.
(cherry picked from commit 266f490)

Co-authored-by: Alexander Buchkovsky <olex.buchkovsky@gmail.com>
@ahcub
Copy link
Contributor Author

ahcub commented Sep 4, 2018

thanks, I will check the backport to 3.6

vstinner pushed a commit that referenced this pull request Sep 4, 2018
…ocess (GH-9027) (GH-9064)

Fix for invalid assert on big output of multiprocessing.Process.
(cherry picked from commit 266f490)

Co-authored-by: Alexander Buchkovsky <olex.buchkovsky@gmail.com>
ahcub added a commit to ahcub/cpython that referenced this pull request Sep 5, 2018
…ing.Process (pythonGH-9027)

Fix for invalid assert on big output of multiprocessing.Process.

(cherry picked from commit 266f490)
@bedevere-bot
Copy link

GH-9069 is a backport of this pull request to the 3.6 branch.

vstinner pushed a commit that referenced this pull request Sep 7, 2018
…ing.Process (GH-9027) (GH-9069)

Fix for invalid assert on big output of multiprocessing.Process.

(cherry picked from commit 266f490)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants