[Python-Dev] new failing test -- test_compiler
Armin Rigo
arigo at tunes.org
Sun Aug 8 00:23:57 CEST 2004
Hi,
On Sat, Aug 07, 2004 at 09:47:22PM +0100, Michael Hudson wrote:
> k = ''
> for node in nodelist:
> k += self.decode_literal(node[1])
>
> what does this make you think of? Yes, it's the new += string
> optimizations; Python gets upset if you mutate interned strings...
>
> Armin is on the case...
Ahem, oups, yes, I am to blame for this memory corruption bug. In the +=
string optimization I forgot that the string's ob_refcnt field is not always
"correct". String interning messes with its value. What occurred here is
that we mutated a string which had only one reference left -- that is, one
apart from the two that stringobject.c artificially removes to ob_refcnt when
interning.
This is now fixed by skipping the optimization if we got an interned string.
While messing with ob_refcnt is always a bit fragile I am still convinced that
the += optimization is safe again.
A bientôt,
Armin.
More information about the Python-Dev
mailing list