[New-bugs-announce] [issue9785] _PyUnicode_New(), throw and memory problem

Trigve Siver report at bugs.python.org
Mon Sep 6 15:25:11 CEST 2010


New submission from Trigve Siver <trigves at gmail.com>:

I'm using C++ with python embeding.
I'm creating a couple of unicode objects and then some
exception is thrown. While handling exception I create othet unicode objects. Then when creating some unicode object crash occurs. The problem is in _PyUnicode_New():325 on line (1):

if (free_list) {
    unicode = free_list; /*<- (1)*/
    free_list = *(PyUnicodeObject **)unicode;

In statement "unicode = free_list;" "unicode" pointer is bad pointer, in fact it's address is 5 bytes "lower" (i.e. should be 0x030bc3ff but is 0x030bc3fa).

It looks like this only happens when exception is thrown.

When python exception is set I throw C++ exception to signal C++ code that py exception was set. Next in C++ exception handler I format the python exception using some python unicode objects and then the problem occurs.
Without the C++ throw (Only python exception formatting) it looks like everything is working OK.

I'm using python 3.1.2 on Vista with MSVS 2010. I've also tried python 3.2a2 but it was the same.

I've tried to isolate the problem in some simple example but haven't been successful yet.

----------
components: Library (Lib)
messages: 115702
nosy: Trigve.Siver
priority: normal
severity: normal
status: open
title: _PyUnicode_New(), throw and memory problem
type: crash
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9785>
_______________________________________


More information about the New-bugs-announce mailing list