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-38168: Fix possible refleaks in setint() of mmapmodule.c #16136

Merged
merged 1 commit into from Sep 16, 2019

Conversation

shihai1991
Copy link
Member

@shihai1991 shihai1991 commented Sep 14, 2019

@matrixise
Copy link
Member

Could you reproduce with a test? and via this command?

./python -m test test_XYZ -R 3:3

replace test_XYZ by a test where you test the memory leak.

@shihai1991
Copy link
Member Author

Could you reproduce with a test? and via this command?

./python -m test test_XYZ -R 3:3

replace test_XYZ by a test where you test the memory leak.

I have the same question too, but i found some PR or bpo no regression test against it :(
[1] #8934
[2] https://bugs.python.org/issue27248

@ghost
Copy link

ghost commented Sep 15, 2019

In current code, if PyDict_SetItemString() fails (return -1), o will not be released.
It's hard to reproduce a leak, it requires harsh condition.

Another way is to use PyModule_AddIntMacro(), and no longer use setint() in Modules/mmapmodule.c.
IMO PyModule_AddIntMacro()is more suitable, but maybe a bit slower.

@shihai1991
Copy link
Member Author

In current code, if PyDict_SetItemString() failes (return -1), o will not be released.
It's hard to reproduce a leak, it requires harsh condition.

Agree.

Another way is to use PyModule_AddIntMacro(), and no longer use setint() in Modules/mmapmodule.c.
IMO PyModule_AddIntMacro()is more suitable, but maybe a bit slower.

I review the PyModule_AddIntMacro code, looks your are right. But as your said, it MAYBE a bit slower.

@ghost
Copy link

ghost commented Sep 16, 2019

I would suggest use "possible" in the title, "Fix possible refleaks..."

@shihai1991 shihai1991 changed the title bpo-38168: Fix refleaks in setint() of mmapmodule.c bpo-38168: Fix possible refleaks in setint() of mmapmodule.c Sep 16, 2019
@shihai1991
Copy link
Member Author

I would suggest use "possible" in the title, "Fix possible refleaks..."

done :)

Copy link
Member

@zhangyangyu zhangyangyu left a comment

Choose a reason for hiding this comment

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

I think for this tiny and clear fix, which also hard to reproduce, it's okay to omit test.

@miss-islington
Copy link
Contributor

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

@bedevere-bot bedevere-bot removed the needs backport to 3.8 only security fixes label Sep 16, 2019
@bedevere-bot
Copy link

GH-16174 is a backport of this pull request to the 3.8 branch.

@bedevere-bot
Copy link

GH-16175 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 16, 2019
(cherry picked from commit 56a4514)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
miss-islington added a commit that referenced this pull request Sep 16, 2019
…H-16136) (GH-16174)

(cherry picked from commit 56a4514)


Co-authored-by: Hai Shi <shihai1992@gmail.com>

https://bugs.python.org/issue38168



Automerge-Triggered-By: @zhangyangyu
miss-islington added a commit that referenced this pull request Sep 16, 2019
…H-16136) (GH-16175)

(cherry picked from commit 56a4514)


Co-authored-by: Hai Shi <shihai1992@gmail.com>

Automerge-Triggered-By: @zhangyangyu
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Sorry, @shihai1991 and @zhangyangyu, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 56a45142e70a1ccf3233d43cb60c47255252e89a 2.7

zhangyangyu added a commit that referenced this pull request Sep 16, 2019
@bedevere-bot
Copy link

GH-16176 is a backport of this pull request to the 2.7 branch.

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows7 SP1 3.7 has failed when building commit e857fe6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/130/builds/1125) and take a look at the build logs.
  4. Check if the failure is related to this commit (e857fe6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/130/builds/1125

Failed tests:

  • test_regrtest

Summary of the results of the build (if available):

== Tests result: FAILURE then SUCCESS ==

382 tests OK.

10 slowest tests:

  • test_io: 3 min 5 sec
  • test_multiprocessing_spawn: 2 min 38 sec
  • test_tools: 2 min 18 sec
  • test_mmap: 1 min 48 sec
  • test_venv: 1 min 47 sec
  • test_tokenize: 1 min 44 sec
  • test_concurrent_futures: 1 min 42 sec
  • test_lib2to3: 1 min 16 sec
  • test_socket: 1 min 3 sec
  • test_asyncio: 55 sec 342 ms

34 tests skipped:
test_crypt test_curses test_dbm_gnu test_dbm_ndbm test_devpoll
test_epoll test_fcntl test_fork1 test_gdb test_grp test_ioctl
test_kqueue test_multiprocessing_fork
test_multiprocessing_forkserver test_nis test_openpty
test_ossaudiodev test_pipes test_poll test_posix test_pty test_pwd
test_readline test_resource test_spwd test_syslog
test_threadsignals test_tix test_tk test_ttk_guionly test_wait3
test_wait4 test_xxtestfuzz test_zipfile64

1 re-run test:
test_regrtest

Total duration: 17 min 16 sec

Click to see traceback logs
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\support\__init__.py", line 310, in _force_run
    return func(*args)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\buildbot.python.org\\3.7.kloth-win64\\build\\build\\test_python_4252\\test_python_worker_3640'


Traceback (most recent call last):
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\__main__.py", line 2, in <module>
    main()
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\libregrtest\main.py", line 689, in main


Traceback (most recent call last):
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\support\__init__.py", line 988, in temp_dir
    yield path
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\support\__init__.py", line 1040, in temp_cwd
    yield cwd_dir
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\libregrtest\main.py", line 623, in main
    self._main(tests, kwargs)
  File "C:\buildbot.python.org\3.7.kloth-win64\build\lib\test\libregrtest\main.py", line 684, in _main
    sys.exit(0)
SystemExit: 0

zhangyangyu added a commit that referenced this pull request Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants