Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b94eef2a
Kaydet (Commit)
b94eef2a
authored
Ara 19, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20191: Fixed a crash in resource.prlimit() when pass a sequence that
doesn't own its elements as limits.
üst
4ec1590f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
33 deletions
+48
-33
test_resource.py
Lib/test/test_resource.py
+14
-0
NEWS
Misc/NEWS
+3
-0
resource.c
Modules/resource.c
+31
-33
No files found.
Lib/test/test_resource.py
Dosyayı görüntüle @
b94eef2a
...
@@ -158,6 +158,20 @@ class ResourceTest(unittest.TestCase):
...
@@ -158,6 +158,20 @@ class ResourceTest(unittest.TestCase):
self
.
assertEqual
(
resource
.
prlimit
(
0
,
resource
.
RLIMIT_AS
,
limit
),
self
.
assertEqual
(
resource
.
prlimit
(
0
,
resource
.
RLIMIT_AS
,
limit
),
limit
)
limit
)
# Issue 20191: Reference counting bug
@unittest.skipUnless
(
hasattr
(
resource
,
'prlimit'
),
'no prlimit'
)
@support.requires_linux_version
(
2
,
6
,
36
)
def
test_prlimit_refcount
(
self
):
class
BadSeq
:
def
__len__
(
self
):
return
2
def
__getitem__
(
self
,
key
):
return
limits
[
key
]
-
1
# new reference
limits
=
resource
.
getrlimit
(
resource
.
RLIMIT_AS
)
self
.
assertEqual
(
resource
.
prlimit
(
0
,
resource
.
RLIMIT_AS
,
BadSeq
()),
limits
)
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
support
.
run_unittest
(
ResourceTest
)
support
.
run_unittest
(
ResourceTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
b94eef2a
...
@@ -130,6 +130,9 @@ Core and Builtins
...
@@ -130,6 +130,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20191: Fixed a crash in resource.prlimit() when pass a sequence that
doesn'
t
own
its
elements
as
limits
.
-
Issue
#
28779
:
multiprocessing
.
set_forkserver_preload
()
would
crash
the
-
Issue
#
28779
:
multiprocessing
.
set_forkserver_preload
()
would
crash
the
forkserver
process
if
a
preloaded
module
instantiated
some
forkserver
process
if
a
preloaded
module
instantiated
some
multiprocessing
objects
such
as
locks
.
multiprocessing
objects
such
as
locks
.
...
...
Modules/resource.c
Dosyayı görüntüle @
b94eef2a
...
@@ -107,29 +107,46 @@ resource_getrusage(PyObject *self, PyObject *args)
...
@@ -107,29 +107,46 @@ resource_getrusage(PyObject *self, PyObject *args)
}
}
static
int
static
int
py2rlimit
(
PyObject
*
curobj
,
PyObject
*
maxobj
,
struct
rlimit
*
rl_out
)
py2rlimit
(
PyObject
*
limits
,
struct
rlimit
*
rl_out
)
{
{
PyObject
*
curobj
,
*
maxobj
;
limits
=
PySequence_Tuple
(
limits
);
if
(
!
limits
)
/* Here limits is a borrowed reference */
return
-
1
;
if
(
PyTuple_GET_SIZE
(
limits
)
!=
2
)
{
PyErr_SetString
(
PyExc_ValueError
,
"expected a tuple of 2 integers"
);
goto
error
;
}
curobj
=
PyTuple_GET_ITEM
(
limits
,
0
);
maxobj
=
PyTuple_GET_ITEM
(
limits
,
1
);
#if !defined(HAVE_LARGEFILE_SUPPORT)
#if !defined(HAVE_LARGEFILE_SUPPORT)
rl_out
->
rlim_cur
=
PyLong_AsLong
(
curobj
);
rl_out
->
rlim_cur
=
PyLong_AsLong
(
curobj
);
if
(
rl_out
->
rlim_cur
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
if
(
rl_out
->
rlim_cur
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
return
-
1
;
goto
error
;
rl_out
->
rlim_max
=
PyLong_AsLong
(
maxobj
);
rl_out
->
rlim_max
=
PyLong_AsLong
(
maxobj
);
if
(
rl_out
->
rlim_max
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
if
(
rl_out
->
rlim_max
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
return
-
1
;
goto
error
;
#else
#else
/* The limits are probably bigger than a long */
/* The limits are probably bigger than a long */
rl_out
->
rlim_cur
=
PyLong_AsLongLong
(
curobj
);
rl_out
->
rlim_cur
=
PyLong_AsLongLong
(
curobj
);
if
(
rl_out
->
rlim_cur
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
if
(
rl_out
->
rlim_cur
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
return
-
1
;
goto
error
;
rl_out
->
rlim_max
=
PyLong_AsLongLong
(
maxobj
);
rl_out
->
rlim_max
=
PyLong_AsLongLong
(
maxobj
);
if
(
rl_out
->
rlim_max
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
if
(
rl_out
->
rlim_max
==
(
rlim_t
)
-
1
&&
PyErr_Occurred
())
return
-
1
;
goto
error
;
#endif
#endif
Py_DECREF
(
limits
);
rl_out
->
rlim_cur
=
rl_out
->
rlim_cur
&
RLIM_INFINITY
;
rl_out
->
rlim_cur
=
rl_out
->
rlim_cur
&
RLIM_INFINITY
;
rl_out
->
rlim_max
=
rl_out
->
rlim_max
&
RLIM_INFINITY
;
rl_out
->
rlim_max
=
rl_out
->
rlim_max
&
RLIM_INFINITY
;
return
0
;
return
0
;
error:
Py_DECREF
(
limits
);
return
-
1
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -172,7 +189,7 @@ resource_setrlimit(PyObject *self, PyObject *args)
...
@@ -172,7 +189,7 @@ resource_setrlimit(PyObject *self, PyObject *args)
{
{
struct
rlimit
rl
;
struct
rlimit
rl
;
int
resource
;
int
resource
;
PyObject
*
limits
,
*
curobj
,
*
maxobj
;
PyObject
*
limits
;
if
(
!
PyArg_ParseTuple
(
args
,
"iO:setrlimit"
,
&
resource
,
&
limits
))
if
(
!
PyArg_ParseTuple
(
args
,
"iO:setrlimit"
,
&
resource
,
&
limits
))
return
NULL
;
return
NULL
;
...
@@ -183,21 +200,8 @@ resource_setrlimit(PyObject *self, PyObject *args)
...
@@ -183,21 +200,8 @@ resource_setrlimit(PyObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
limits
=
PySequence_Tuple
(
limits
);
if
(
py2rlimit
(
limits
,
&
rl
)
<
0
)
{
if
(
!
limits
)
/* Here limits is a borrowed reference */
return
NULL
;
return
NULL
;
if
(
PyTuple_GET_SIZE
(
limits
)
!=
2
)
{
PyErr_SetString
(
PyExc_ValueError
,
"expected a tuple of 2 integers"
);
goto
error
;
}
curobj
=
PyTuple_GET_ITEM
(
limits
,
0
);
maxobj
=
PyTuple_GET_ITEM
(
limits
,
1
);
if
(
py2rlimit
(
curobj
,
maxobj
,
&
rl
)
<
0
)
{
goto
error
;
}
}
if
(
setrlimit
(
resource
,
&
rl
)
==
-
1
)
{
if
(
setrlimit
(
resource
,
&
rl
)
==
-
1
)
{
...
@@ -209,15 +213,9 @@ resource_setrlimit(PyObject *self, PyObject *args)
...
@@ -209,15 +213,9 @@ resource_setrlimit(PyObject *self, PyObject *args)
"not allowed to raise maximum limit"
);
"not allowed to raise maximum limit"
);
else
else
PyErr_SetFromErrno
(
PyExc_OSError
);
PyErr_SetFromErrno
(
PyExc_OSError
);
goto
error
;
return
NULL
;
}
}
Py_DECREF
(
limits
);
Py_RETURN_NONE
;
Py_INCREF
(
Py_None
);
return
Py_None
;
error:
Py_DECREF
(
limits
);
return
NULL
;
}
}
#ifdef HAVE_PRLIMIT
#ifdef HAVE_PRLIMIT
...
@@ -227,10 +225,10 @@ resource_prlimit(PyObject *self, PyObject *args)
...
@@ -227,10 +225,10 @@ resource_prlimit(PyObject *self, PyObject *args)
struct
rlimit
old_limit
,
new_limit
;
struct
rlimit
old_limit
,
new_limit
;
int
resource
,
retval
;
int
resource
,
retval
;
pid_t
pid
;
pid_t
pid
;
PyObject
*
curobj
=
NULL
,
*
maxobj
=
NULL
;
PyObject
*
limits
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_PID
"i|
(OO)
:prlimit"
,
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_PID
"i|
O
:prlimit"
,
&
pid
,
&
resource
,
&
curobj
,
&
maxobj
))
&
pid
,
&
resource
,
&
limits
))
return
NULL
;
return
NULL
;
if
(
resource
<
0
||
resource
>=
RLIM_NLIMITS
)
{
if
(
resource
<
0
||
resource
>=
RLIM_NLIMITS
)
{
...
@@ -239,8 +237,8 @@ resource_prlimit(PyObject *self, PyObject *args)
...
@@ -239,8 +237,8 @@ resource_prlimit(PyObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
if
(
curobj
!=
NULL
)
{
if
(
limits
!=
NULL
)
{
if
(
py2rlimit
(
curobj
,
maxobj
,
&
new_limit
)
<
0
)
{
if
(
py2rlimit
(
limits
,
&
new_limit
)
<
0
)
{
return
NULL
;
return
NULL
;
}
}
retval
=
prlimit
(
pid
,
resource
,
&
new_limit
,
&
old_limit
);
retval
=
prlimit
(
pid
,
resource
,
&
new_limit
,
&
old_limit
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment