#443 win32ui crash in embedded app (212 -> 213 & 214 regression)

win32 (141)

I have an application that embeds python and uses the win32ui module. Everything worked fine until I upgraded from 212 to 214. After the upgrade my application crashes on exit. The Visual Studio debugger is showing that the crash is occurring after my application calls CoUninitialize. Here is a rough outline of what my app does:

RunPythonCode() //This code will import win32ui

Simply importing the win32ui module causes the crash. I don't even need to call any of the modules functions. If I don't import win32ui then my application exits cleanly. I tried downgrading to version 213 but the crash still occurs. Version 212 seems to be the last version that was stable with my application.


  • Farshid Lashkari

    Forgot to mention that I'm using Python 2.4 & 2.6, and both exhibit the same behavior.

  • Mark Hammond

    Mark Hammond - 2010-08-30
    • status: open --> pending
  • Mark Hammond

    Mark Hammond - 2010-08-30

    I'm going to need either a repo or more details information on the crash.

  • Farshid Lashkari

    Sample program to reproduce error

  • Farshid Lashkari

    I just attached a simple console app that reproduces the issue for me using Python 2.7.

  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

  • SourceForge Robot

    • status: pending --> closed
  • Mark Hammond

    Mark Hammond - 2010-09-30

    I tried to reproduce this but hit manifest related issues trying python 2.6 - what python version are you using?

  • Mark Hammond

    Mark Hammond - 2010-09-30
    • status: closed --> open
  • Christoph Gohlke

    I can reproduce the crash with pywin32-214.win-amd64-py2.6 and main.cpp.

    The following code worked for me when compiled with msvc9 "cl.exe main.cpp /MD /link python26.lib ole32.lib":

    #include "Python.h"
    #include <windows.h>

    int main( int argc, char **argv )
    PyRun_SimpleString("import win32ui");
    return 0;

  • Mark Hammond

    Mark Hammond - 2010-09-30

    I can reproduce a problem after Py_Finalize is called - win32ui is trying to process a message (presumably sent during CoUninitialize) and getting upset as Python has been torn down. I can't explain how that has changed in recent versions though. If I change the example to CoUninitialize before the finalize everything seems to work fine.

  • Farshid Lashkari

    I've experienced this crash on 2.4, 2.6, and 2.7.

    Since reporting this issue, I've abandoned the use of win32ui, so it's not a big deal for me anymore. But if you come up with a fix, I am willing to test it out.


    s ANCELOT - 2011-12-12

    I have exactly the same problem using python 2.6 32 bits version on win7 64 bits.

    on a win32 32 bits platform it has worked, but It did when launching the same application on 64 bits platform.
    after lot of researchs I found that loading win32ui was the problem.

    I tried the 212 build and the problem disappeared.

    I think it does not seem complicated to watch at changes between 212 and 216 build.?

  • Gary Bloom

    Gary Bloom - 2013-01-05

    I see a similar (and I'm sure related) problem. The following Python code snippet causes a hang on exit:

    import Tkinter
    import win32ui #including this library causes hang on exit

    master = Tkinter.Tk()
    #Label not needed to reproduce hang
    Tkinter.Label(text=" Will hang on exit if win32ui has been imported ").pack()

    This regression problem did not exist with PyWin32-212. It began with 213 and still exists in every version since then, up to 218.
    I build and test with 32-bit Python on Win7 (both 32-bit and 64-bit platforms). The problem exists in 32-bit Python on both platforms. I haven't looked at 64-bit Python.

    This bug is preventing me from upgrading my build to Python 2.7, because:
    1) I need pywin32,
    2) pywin32-212 is the last version that does not have the hang regression, and
    3) pywin32-212 Windows builds stop at Python 2.6.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks