You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, memory management for the Py_tp_doc slot in PyType_FromSpec is ill-defined. The doc string being passed is stored in the type object as-is, but later released with PyObject_Free. To make this consistent, PyType_FromSpec should copy the string, so that it's guaranteed that relasing the memory matches allocation.
Without this patch, users will have to hold onto the type objects they get from PyType_FromSpec "forever".
Sounds like a blocker to me. Martin, will you be able to provide a patch before final?
loewis commented on Feb 19, 2011
loewismannequin
MannequinAuthor
More actions
Well, isn't Py_tp_doc characteristically bound to a constant char *
That's exactly the problem: PyType_FromSpec puts in this string literal.
When the type is later released, PyObject_Free is called in
type_dealloc, which segfaults.
loewis commented on Feb 19, 2011
loewismannequin
MannequinAuthor
More actions
Sounds like a blocker to me. Martin, will you be able to provide a patch before final?
>>> Sounds like a blocker to me. Martin, will you be able to provide a patch before final?
>>
>> The attached patch works fine for me.
>
> Is there some documentation somewhere for all this?
Can you please be more specific? What's "all this"?
That tp_doc will be copied is currently undocumented. PyType_FromSpec
is documented in the PEP.
I meant all of py_tp_doc, "limited api", "restricted api" show almost
zero hits in the API docs. A PEP is nice but I'm not sure many people
spontaneously read PEPs.
loewis commented on Feb 19, 2011
loewismannequin
MannequinAuthor
More actions
> That tp_doc will be copied is currently undocumented. PyType_FromSpec
> is documented in the PEP.
I meant all of py_tp_doc, "limited api", "restricted api" show almost
zero hits in the API docs. A PEP is nice but I'm not sure many people
spontaneously read PEPs.
No, there is no documentation in the Doc directory. I *would* expect
that people interested in using the stable ABI do find the PEP and
read it. With the exception of this issue, I consider the PEP to be
complete and correct documentation (of course, it probably contains
errors that I'm unaware of).
However, documentation for the PEP-384 changes seems to be an
unrelated issue.
Activity
loewis commentedon Feb 19, 2011
Currently, memory management for the Py_tp_doc slot in PyType_FromSpec is ill-defined. The doc string being passed is stored in the type object as-is, but later released with PyObject_Free. To make this consistent, PyType_FromSpec should copy the string, so that it's guaranteed that relasing the memory matches allocation.
Without this patch, users will have to hold onto the type objects they get from PyType_FromSpec "forever".
pitrou commentedon Feb 19, 2011
Sure it should be a blocker?
loewis commentedon Feb 19, 2011
If this isn't added, people using the API might see crashes. If they then work around crashes, they will see memory leaks in future releases.
pitrou commentedon Feb 19, 2011
Well, isn't Py_tp_doc characteristically bound to a constant char *, so that the problem doesn't manifest itself?
birkenfeld commentedon Feb 19, 2011
Sounds like a blocker to me. Martin, will you be able to provide a patch before final?
loewis commentedon Feb 19, 2011
That's exactly the problem: PyType_FromSpec puts in this string literal.
When the type is later released, PyObject_Free is called in
type_dealloc, which segfaults.
loewis commentedon Feb 19, 2011
The attached patch works fine for me.
pitrou commentedon Feb 19, 2011
Is there some documentation somewhere for all this?
loewis commentedon Feb 19, 2011
Can you please be more specific? What's "all this"?
That tp_doc will be copied is currently undocumented. PyType_FromSpec
is documented in the PEP.
pitrou commentedon Feb 19, 2011
I meant all of py_tp_doc, "limited api", "restricted api" show almost
zero hits in the API docs. A PEP is nice but I'm not sure many people
spontaneously read PEPs.
loewis commentedon Feb 19, 2011
No, there is no documentation in the Doc directory. I *would* expect
that people interested in using the stable ABI do find the PEP and
read it. With the exception of this issue, I consider the PEP to be
complete and correct documentation (of course, it probably contains
errors that I'm unaware of).
However, documentation for the PEP-384 changes seems to be an
unrelated issue.
birkenfeld commentedon Feb 19, 2011
OK, committed in r88443 (with error handling made more consistent).
BTW, the return from PyType_GenericAlloc isn't NULL-checked, which looks like a potential crasher to me. Not release-critical though.