473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Debug build without PYMALLOC

Hello,

When debugging C extensions, I find the most difficult is to detect
that an object is Py_DECREF'ed when it should not.
And when you find yourself with an invalid object, it's a nightmare to
find where the error occured!
Normally tools like Purify are good to find this kind of memory
errors, but they are of no use with python's own memory allocator.

That's why I recompiled python (on Windows) in debug mode after
removing the WITH_PYMALLOC option.
This worked very well: Purify warned about a "Free memory read", and
it turned out that a custom sys.stdout was incorrectly DECREF'ed just
before, which caused the crash.

The problem is that this python build (debug/without-pymalloc) is not
compatible with extension modules built WITH_pymalloc. The DLL loader
fails with a "missing _PyObject_DebugMalloc" error.
Note that with release builds, extensions built with pymalloc are
compatible with python.dll built without pymalloc.

My workaround was to add the three functions (_PyObject_DebugMalloc,
*Realloc and *Free) in obmalloc.c.
Isn't there another way?
Otherwise, should this be integrated in Python?

Thanks,
Amaury.

Jul 18 '05 #1
1 2379
"Amaury" <am*******@yahoo.com> writes:
Hello,

When debugging C extensions, I find the most difficult is to detect
that an object is Py_DECREF'ed when it should not.
And when you find yourself with an invalid object, it's a nightmare to
find where the error occured!
Normally tools like Purify are good to find this kind of memory
errors, but they are of no use with python's own memory allocator.

That's why I recompiled python (on Windows) in debug mode after
removing the WITH_PYMALLOC option.
This worked very well: Purify warned about a "Free memory read", and
it turned out that a custom sys.stdout was incorrectly DECREF'ed just
before, which caused the crash.

The problem is that this python build (debug/without-pymalloc) is not
compatible with extension modules built WITH_pymalloc. The DLL loader
fails with a "missing _PyObject_DebugMalloc" error.
Note that with release builds, extensions built with pymalloc are
compatible with python.dll built without pymalloc.
Hmm, that makes sense but I hadn't thought of it before. You could
also have recompiled the extensions, though.
My workaround was to add the three functions (_PyObject_DebugMalloc,
*Realloc and *Free) in obmalloc.c.
Isn't there another way?
Otherwise, should this be integrated in Python?


Possibly. Post a bug report or maybe a patch to SF if you feel
strongly about it...

Cheers,
mwh

--
If you don't use emacs, you're a pathetic, mewling, masochistic
weakling and I can't be bothered to convert you. -- Ron Echeverri
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Smith | last post by:
Sorry if this is the wrong forum... Does anyone know what the difference is between a debug build and an optimised debug build in Visual Studio 2003?
4
by: emma middlebrook | last post by:
I have a question regarding asserting ... here's some code: string GetAssertMessage() { ... prepare a message string and return it... } void SomeMethod() { ...
2
by: babyx | last post by:
The release build class library can only work with msvcr71d.dll and msvcp71d.dll exist. How to make this class library work on any machine without using the debug dlls? What are the project...
1
by: Brian | last post by:
Can sombody please outline the diference between setting complication mode from the toolbar in VS.Net (i.e. debug/release) and setting the debug attribute (i.e. true/false) on the compilation...
6
by: Boni | last post by:
Dear all, I have following problem. I created a static libruary (mylib.lib). I compiled it with Multithreaded DLL runtime in release mode. Now I want to give out this library. But users who...
6
by: William E Voorhees | last post by:
I've just installed visual studio 2005. When I make code or form changes and start debug (run program) my changes aren't seen unless I build the program first. In 2003, I didn't have to build the...
3
by: Bardo | last post by:
Hi all, We are trying to debug an assembly which was built in debug configuration on our build server. The output window of visual studio indicates that no symbols are being loaded for the...
6
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi there We are trying to build a C sharp solution in Visual Studio 2005 Professional. We have a number of other assemblies, that do not form part of the solution. Assemblies that do form...
3
by: Bev in TX | last post by:
I am a complete newbie at building Python. I am trying to build it under MS Windows Vista (64-bit AMD) with MS VS2005. I'm doing that because I need debug libraries, which I did not see in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.