[Python-Dev] Disabling string interning for null and single-char causes segfaults

Antoine Pitrou solipsis at pitrou.net
Sun Mar 3 00:36:36 CET 2013


On Sat, 2 Mar 2013 22:13:56 +0100
Stefan Bucur <stefan.bucur at gmail.com> wrote:

> On Sat, Mar 2, 2013 at 4:31 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > On Fri, 1 Mar 2013 16:24:42 +0100
> > Stefan Bucur <stefan.bucur at gmail.com> wrote:
> >>
> >> However, after applying this modification, when running "make test" I get a
> >> segfault in the test___all__ test case.
> >>
> >> Before digging deeper into the issue, I wanted to ask here if there are any
> >> implicit assumptions about string identity and interning throughout the
> >> interpreter implementation. For instance, are two single-char strings
> >> having the same content supposed to be identical objects?
> >
> > From a language POV, no, but inside a specific interpreter such as
> > CPython it may be a reasonable expectation.
> >
> >> I'm assuming that it's either this, or some refcount bug in the interpreter
> >> that manifests only when certain strings are no longer interned and thus
> >> have a higher chance to get low refcount values.
> >
> > Indeed, if it's a real bug it would be nice to get it fixed :-)
> 
> By the way, in that case, what would be the best way to debug such
> type of ref count errors? I recently ran across this document [1],
> which kind of applies to debugging focused on newly introduced code.

That documents looks a bit outdated (1998!).
I would suggest you enable core dumps (`ulimit -c unlimited`), then let
Python crash and inspect the stack trace with gdb.
You will get better results if using a debug build and the modern gdb
inspection helpers:
http://docs.python.org/devguide/gdb.html

Oh, by the way, it would be better to do your work on Python 3 rather
than 2.7. Either the `default` branch or the `3.3` branch, I guess.
See http://docs.python.org/devguide/setup.html#checkout

Regards

Antoine.


More information about the Python-Dev mailing list