[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 38e32872eb3cf0dc9dd8cef9b05e47ba03638d34 by Miss Islington (bot) 
in branch '3.8':
bpo-41344: Raise ValueError when creating shared memory of size 0 (GH-21556) 
(GH-22019)
https://github.com/python/cpython/commit/38e32872eb3cf0dc9dd8cef9b05e47ba03638d34


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Thanks for the report and the PR, vinay0410!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset ca55ecbf9aab305fa301ec69410ca3d3d18ec848 by Miss Islington (bot) 
in branch '3.9':
bpo-41344: Raise ValueError when creating shared memory of size 0 (GH-21556) 
(GH-22018)
https://github.com/python/cpython/commit/ca55ecbf9aab305fa301ec69410ca3d3d18ec848


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21119
pull_request: https://github.com/python/cpython/pull/22019

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 475a5fbb5644ea200c990d85d8c264e78ab6c7ea by Vinay Sharma in 
branch 'master':
bpo-41344: Raise ValueError when creating shared memory of size 0 (GH-21556)
https://github.com/python/cpython/commit/475a5fbb5644ea200c990d85d8c264e78ab6c7ea


--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-08-30 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +21118
pull_request: https://github.com/python/cpython/pull/22018

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


Removed file: https://bugs.python.org/file49339/-.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


Removed file: https://bugs.python.org/file49338/lose.html

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-25 Thread 5YN15T3R_742 SeT1aP DeTiK


Change by 5YN15T3R_742 SeT1aP DeTiK :


Added file: https://bugs.python.org/file49339/-.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-25 Thread 5YN15T3R_742 SeT1aP DeTiK


Change by 5YN15T3R_742 SeT1aP DeTiK :


Added file: https://bugs.python.org/file49338/lose.html

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-24 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

No, I think ValueError on all systems is better.  I have no idea what 
'wnsm_4ab39616' is about other than something internal to Windows.  It does not 
say what to do to correct the call.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-24 Thread Vinay Sharma


Vinay Sharma  added the comment:

Also, Linux created the shared memory with the passed name if size = 0, but 
threw error when it was being mapped to the process's virtual memory. 
Therefore, this scenario should be prevented before actually creating the 
shared memory segment in cases of Linux.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-24 Thread Vinay Sharma


Vinay Sharma  added the comment:

Hi, The patch aims to raise a value error, because before the patch also, 
ValueError was being raised in case size was negative. That's why I thought it 
would be correct behaviour if I raise ValueError in case size is 0.

Do you mean to say, that OSError should be raise in the case size=0.
Also, I think handling of Windows was fine even before the patch, it was MacOS 
and Linux which were causing problems.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-24 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Python 3.10.0a0  Jul 23 2020, win32 (without patch)

>>> from multiprocessing import shared_memory
>>> shm_a = shared_memory.SharedMemory(create=True, size=0)
Traceback (most recent call last):
  File "", line 1, in 
shm_a = shared_memory.SharedMemory(create=True, size=0)
  File "f:\dev\3x\lib\multiprocessing\shared_memory.py", line 129, in __init__
h_map = _winapi.CreateFileMapping(
OSError: [WinError 87] The parameter is incorrect: 'wnsm_4ab39616'

After the patch, I get the value error.

--
nosy: +terry.reedy
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-20 Thread SilentGhost


Change by SilentGhost :


--
nosy: +davin, pitrou
type: crash -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-20 Thread Vinay Sharma


Change by Vinay Sharma :


--
keywords: +patch
pull_requests: +20702
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21556

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41344] SharedMemory crash when size is 0

2020-07-20 Thread Vinay Sharma


New submission from Vinay Sharma :

On running this: shm = SharedMemory(create=True, size=0)
I get the following error:



Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/multiprocessing/shared_memory.py", line 111, in 
__init__
self._mmap = mmap.mmap(self._fd, size)
ValueError: cannot mmap an empty file
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in 
apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in 
from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 

from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in 

import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/multiprocessing/shared_memory.py", line 111, in 
__init__
self._mmap = mmap.mmap(self._fd, size)
ValueError: cannot mmap an empty file
>>> shm = SharedMemory(create=True, size=0)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/multiprocessing/shared_memory.py", line 111, in 
__init__
self._mmap = mmap.mmap(self._fd, size)
ValueError: cannot mmap an empty file
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in 
apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in 
from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 

from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in 

import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/multiprocessing/shared_memory.py", line 111, in 
__init__
self._mmap = mmap.mmap(self._fd, size)
ValueError: cannot mmap an empty file


This can be simply resolved by adding a check when size passed is 0, so that a 
shared memory segment is never created.
Currently, the following is coded:

if not size >= 0:
raise ValueError("'size' must be a positive integer")

I believe this should be changed to:
if not size > 0:
raise ValueError("'size' must be a positive integer")

As zero is not a positive and integer and is causing problems.

--
components: Library (Lib)
messages: 373990
nosy: vinay0410
priority: normal
severity: normal
status: open
title: SharedMemory crash when size is 0
type: crash
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com