calling PyTasklet_New( NULL, ...) crashes
"Liu, Jun" <jliu-A5I17ULcEI2KIZPZH7ozwQC/[email protected]> Tue, 11 Apr 2017 23:06:01 +0000
| Newsgroups | gmane.comp.python.stackless |
|---|---|
| Message-ID | <[email protected]> |
--===============7033201160711014894==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_822E24E81E506343AD9B6261DF9E905AB1F98Amailsd03adsoesony_"
--_000_822E24E81E506343AD9B6261DF9E905AB1F98Amailsd03adsoesony_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi,
I am using stackless python 3.4.2. I'd like to know if anyone that has use=
d PyTasklet_New function encountered the same problem when passing in NULL =
as the first argument. According to the documentation,
"PyTaskletObject *PyTasklet_New(PyTypeObject *type, PyObject *func)
Return a new tasklet object. type must be derived from PyTasklet_Type or NU=
LL. func must be a callable object (normal use-case) or NULL, if the taskle=
t is being used via capture()."
But it crashes when I pass in NULL as first argument. I looked at the sourc=
e code, and it is:
PyTasklet_New(PyTypeObject *type, PyObject *func)
{
if (!PyType_IsSubtype(type, &PyTasklet_Type)) {
PyErr_SetNone(PyExc_TypeError);
return NULL;
}
......
}
int
PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
{
PyObject *mro;
mro =3D a->tp_mro;
....
}
So the pointer is dereferenced without being checked thus causing the crash=
?
Jun
--_000_822E24E81E506343AD9B6261DF9E905AB1F98Amailsd03adsoesony_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
code
{mso-style-priority:99;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.sig-paren
{mso-style-name:sig-paren;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.pre
{mso-style-name:pre;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi, <o:p></o:p></p>
<p class=3D"MsoNormal">I am using stackless python 3.4.2. I’d l=
ike to know if anyone that has used PyTasklet_New function encountered the =
same problem when passing in NULL as the first argument. According to the d=
ocumentation,
<o:p></o:p></p>
<p class=3D"MsoNormal">“PyTaskletObject *PyTasklet_New(PyTypeObject *=
type, PyObject *func)
<o:p></o:p></p>
<p class=3D"MsoNormal">Return a new tasklet object. type must be derived fr=
om PyTasklet_Type or NULL. func must be a callable object (normal use-case)=
or NULL, if the tasklet is being used via capture().“<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">But it crashes when I pass in NULL as first argument=
. I looked at the source code, and it is:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">PyTasklet_New(PyTypeObject *type, PyObject *func)<o:=
p></o:p></p>
<p class=3D"MsoNormal">{<o:p></o:p></p>
<p class=3D"MsoNormal"> if (!PyType_IsSubtype(type, &=
PyTasklet_Type)) {<o:p></o:p></p>
<p class=3D"MsoNormal"> PyErr_Set=
None(PyExc_TypeError);<o:p></o:p></p>
<p class=3D"MsoNormal"> return NU=
LL;<o:p></o:p></p>
<p class=3D"MsoNormal"> }<o:p></o:p></p>
<p class=3D"MsoNormal"> ......<o:p></o:p></p>
<p class=3D"MsoNormal">}<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">int<o:p></o:p></p>
<p class=3D"MsoNormal">PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)<o=
:p></o:p></p>
<p class=3D"MsoNormal">{<o:p></o:p></p>
<p class=3D"MsoNormal"> PyObject *mro;<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> mro =3D a->tp_mro;<o:p></o:p><=
/p>
<p class=3D"MsoNormal"> &nbs=
p; ....<o:p></o:p></p>
<p class=3D"MsoNormal">}<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">So the pointer is dereferenced without being checked=
thus causing the crash?<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Jun<o:p></o:p></p>
</div>
</body>
</html>
--_000_822E24E81E506343AD9B6261DF9E905AB1F98Amailsd03adsoesony_--
--===============7033201160711014894==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KU3RhY2tsZXNz
IG1haWxpbmcgbGlzdApTdGFja2xlc3NAc3RhY2tsZXNzLmNvbQpodHRwOi8vd3d3LnN0YWNrbGVz
cy5jb20vbWFpbG1hbi9saXN0aW5mby9zdGFja2xlc3M=
--===============7033201160711014894==--