Corrupted C Runtime on app exit via Dispatch

R

rsybel

I'm new to Python, but I am trying to support a product at work. We're
running under Win XP, using Python 2.4.

We're using Python to run optimizations, generating a bunch of test
conditions and having existing products evaluate the solutions.

The programs we're running are MFC apps, built with VS 2003. (Although
they are really old MFC apps). I can run the apps by hand and NEVER
have a problem, only when they are invoked via Python Dispatch.

We invoke a program via Dispatch, run some tests, save the output
file, then tell the program to exit. I've tried various ways to shut
the program down, they don't seem to matter. They all shut down
properly as far as I can tell

The main process has indicated it has exited. The process still exists
in Task Manager for a short while.

After running successfully a few times, the exiting process will
finally crash in "HeapFree" in free.c. Dissecting the remains, the
heap looks like it's already been freed, or it's subtlely corrupted
(only the Blink and Flink pointers are trashed - memory contents look
good).

The crashing code can be almost anything - boost libraries, core code,
CStrings, etc. It appears this is C Runtime cleanup on exit, it
ALWAYS crashes in crt0dat.c, in the __onexitbegin cleanup loop.

I trying to get a handle on what's happening. Is this a mismatch
library problem? I've gone through and made everything consistent,
using msvcr71.dll. Is this a Python threading incompatibility with
Windows?

My Python exit code looks (at the moment) like this;

app.ExitApplication()
app=None
collect()
pythoncom.CoUninitialize()

I've imported gc, I was hoping forcing a garbage collection would help
this problem - nothing substantial has come out of that.

At this point, app.ExitApplication closes all documents and processes
a SendMessage(WM_CLOSE,0,0). Nothing fancy.

And, or course, this never happens in Debug mode. Only in release
builds. I've got debug symbols in the main code and in the libraries
we build, but 3rd party DLLs / libs don't have symbols.

Can someone with more Python experience point me in a general
direction?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top