Message40466
Logged In: YES
user_id=6380
> - why does this try to "fix" the problem of
> dangling interned strings? AFAICT: if there is a
> reference to an interned string at the time
> _Py_ReleaseInternedStrings is called, that
> reference is silently dropped, and a later
> DECREF will result in memory corruption. IOW: it
> should merely set the state of all strings to
> normal, and clear the dict.
Note that the *only* time when
_Py_ReleaseInternedStrings() can ever be called is
at program exit, just before you run a memory leak
detector. There's no way Python can be
resurrected after _Py_ReleaseInternedStrings() has
run.
> - Replacing PyString_InternInPlace with
> PyString_Intern seems dangerous. AFAICT, the
> fragment
>
> PyString_InternInPlace(&name);
> Py_DECREF(name);
> return PyString_AS_STRING(name);
>
> from getclassname would break: Intern() would
> return the only reference to the interned string
> (assuming this is the first usage), and
> getclassname drops this reference, returning a
> pointer to deallocated memory. I'm not sure
> though why getclassname interns the result in
> the first place.
getclassname() is doing something very unsavory
here! I expect that its API will have to be
changed to copy the name into a buffer provided by
the caller.
We'll have to scrutinize all calls for tricks like
this.
> Selectively replacing them might be a good idea,
> though. For intern(), I think an optional
> argument strongref needs to be provided (the
> interned dict essentially weak-references the
> strings). Perhaps the default even needs to be
> weakref.
So do you think there's a need for immortal
strings? What is that need?
|
|
Date |
User |
Action |
Args |
2007-08-23 15:13:56 | admin | link | issue576101 messages |
2007-08-23 15:13:56 | admin | create | |
|