Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Py_Main/PySys_SetArgvEx(...) UCS4/PY3 no mem #399

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

Merged
merged 2 commits into from
Feb 26, 2017

Conversation

vmuriart
Copy link
Contributor

@vmuriart vmuriart commented Feb 22, 2017

What does this implement/fix? Explain your changes.

Fix Py_Main & PySys_SetArgvEx execution on PY3/UCS4 (Linux).

Does this close any currently open issues?

N/A

Any other comments?

Based on @dmitriyse's work.
dmitriyse@8a70f09

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • Add yourself to AUTHORS

@vmuriart vmuriart added this to the 2.3.0 milestone Feb 22, 2017
@vmuriart vmuriart self-assigned this Feb 22, 2017
@den-run-ai
Copy link
Contributor

@vmuriart will this cherry pick include @dmitriyse in the commit history?

@vmuriart
Copy link
Contributor Author

I didn't cherry pick this commit in this case. He had re-organized/re-structured his files and was going to be a headache to cherry pick. I gave him credit on the commit message though. @dmitriyse are you ok w this?

@filmor
Copy link
Member

filmor commented Feb 22, 2017

You can just do a git commit --amend --author "Something <something>" to give credit :)

Could you or @dmitriyse explain why this fixes the issue?

@vmuriart vmuriart force-pushed the fix-pymain_setargv-py3ucs4 branch from c3f5ee5 to 445c4e3 Compare February 22, 2017 20:22
@vmuriart
Copy link
Contributor Author

@filmor good call. Fixed and pushed.

@codecov
Copy link

codecov bot commented Feb 22, 2017

Codecov Report

Merging #399 into master will decrease coverage by -0.09%.
The diff coverage is 51.42%.

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
- Coverage   63.53%   63.45%   -0.09%     
==========================================
  Files          60       60              
  Lines        5222     5257      +35     
  Branches      858      860       +2     
==========================================
+ Hits         3318     3336      +18     
- Misses       1684     1701      +17     
  Partials      220      220
Flag Coverage Δ
#Embedded_Tests 33% <51.42%> (+0.12%)
#Python_Tests 60.07% <51.42%> (-0.42%)
#Setup_Linux 74.5% <51.42%> (ø)
#Setup_Windows 70.5% <51.42%> (ø)
Impacted Files Coverage Δ
src/runtime/runtime.cs 80.74% <51.42%> (-3.94%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4ed645...9b70892. Read the comment docs.

@vmuriart
Copy link
Contributor Author

@filmor I'll let @dmitriyse since he figured it out. My best educated guess is that the encoding was breaking for UCS4 and thus why we only saw the issue on linux.

@den-run-ai
Copy link
Contributor

This code definitely needs comments on how these unmanaged strings are manually built.

I'm surprised that it has to be so convoluted. Why can't we just use PyString_* methods?

@vmuriart
Copy link
Contributor Author

@denfromufa I have some work to refactor that logic. We have about 3 different variations of this same thing, each variation being used atleast twice. When I tried refactoring earlier, I was having issues that either the memory was being freed-up too early or never at all. We do the same thing on PyString_* as this cuz of the same memory life issue.

I settled for this pr until I get the memory-life tuned just right.

@den-run-ai
Copy link
Contributor

@vmuriart can you point to "3 different variations of this same thing, each variation being used atleast twice."?

@vmuriart vmuriart force-pushed the fix-pymain_setargv-py3ucs4 branch from 445c4e3 to 0314334 Compare February 24, 2017 07:04
@vmuriart
Copy link
Contributor Author

@filmor I took a closer look at the issue and I was on the right track. Currently we don't distinguish between the two different encoding, and fails to work on UCS4. This implementation manually marshals the string array and applies to correct encoding passing it to python.

I'm working on an ICustomMarshaler to replace all instances that were are doing this, but I would prefer to have time one in the git-history so that we can fall-back to in case the ICustomMarshaler causes issues.

that being said, @filmor @denfromufa any objections to merging this then?

@dmitriyse
Copy link
Contributor

dmitriyse commented Feb 25, 2017

Hi! There is a problem with ICustomMarshaler - it's not supported by CoreCLR. Please consider to use two Methods solution: First Method - is interop; Second method - is interop wrapper with marshaling inside.
If we want to have single code base and avoid lots of merges and cherry picks. We needs to think in terms of the future adoptions.

@dmitriyse
Copy link
Contributor

Ups, i am worng.
https://github.com/dotnet/corefx/issues/1346
ICustomMarshaler is coming back in NetStandard 2.0
So we can use it. Everybody will migrate to NetStandard 2.0 after this march.

@vmuriart vmuriart force-pushed the fix-pymain_setargv-py3ucs4 branch from 0314334 to 9512475 Compare February 25, 2017 14:41
@vmuriart
Copy link
Contributor Author

@dmitriyse your first comment scared me. You posted it just has I was finishing writing the 2nd ICustomMarshaler.

@vmuriart vmuriart force-pushed the fix-pymain_setargv-py3ucs4 branch from 9512475 to 8ff338a Compare February 25, 2017 15:47
@vmuriart vmuriart merged commit 289d29d into pythonnet:master Feb 26, 2017
@vmuriart vmuriart deleted the fix-pymain_setargv-py3ucs4 branch February 26, 2017 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants