wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.29k stars 516 forks source link

Logger based on TextCtrl crashes python process #562

Open bpaczkowski opened 6 years ago

bpaczkowski commented 6 years ago

Operating system: Windows 10 wxPython version: wxPython 4.0.0b2 Stock or custom build: Stock Python version: 3.6.2 Stock or custom build: Stock

Description of the problem:

I have a very simple logger based on the TextCtrl control. My problem is that very often when closing the application the python process crashes with the following exit code: 0xC0000409. The exception seems to originate in the ucrtbase.dll library, according to VS2017 debugger.

The bare minimum control that causes the crash:

import wx

class LogTextCtrl(wx.TextCtrl):
    def log(self, message):
        self.AppendText(message)
RobinD42 commented 6 years ago

Is it possible that there are messages being logged while (or after) the text ctrl or its parents are being destroyed? Is it possible that the log method is being called directly from another thread?

bpaczkowski commented 6 years ago

It shouldn't, the logging is done from the parent, and I check if the TextCtrl is falsey so it doesn't try to log on a destroyed control. But if in the parent I directly call the AppendText instead of log it never crashes for some reason, I have no idea why.

infinity77 commented 3 weeks ago

@bpaczkowski : are you calling LogMessage from another thread? If you are, then don’t. Is this still relevant? I never had a problem with doing this.