Issue 9785: _PyUnicode_New(), throw and memory problem (original) (raw)
Issue9785
Created on 2010-09-06 13:25 by Trigve.Siver, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg115702 - (view) | Author: Trigve Siver (Trigve.Siver) | Date: 2010-09-06 13:25 |
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. | ||
msg115714 - (view) | Author: Trigve Siver (Trigve.Siver) | Date: 2010-09-06 16:27 |
I've tried to examine it in more depth. Setting the python exception isn't necessary, only throwing the C++ exception is needed for demonstrating the problem. Also sometimes the address is 6 bytes "lower" than should be. | ||
msg115721 - (view) | Author: Trigve Siver (Trigve.Siver) | Date: 2010-09-06 17:17 |
Nevermind, I found out it was problem with ref count while using PyTuple_SetItem() |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:06 | admin | set | github: 53994 |
2010-09-06 17:17:59 | Trigve.Siver | set | status: open -> closedresolution: not a bugmessages: + |
2010-09-06 16:27:53 | Trigve.Siver | set | messages: + |
2010-09-06 13:25:10 | Trigve.Siver | create |