wxGUIEventLoop Null-Ptr-Exception

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Tue Jan 22, 2019 9:50 am

Hi,

I upgraded to wxWidgets 3.1.1 (vs2015, C++) in order to use the changes to wxWebView.
I changed the the backend of the WebView to MiniBlink with code from GitHub:
https://github.com/imReker/wxWebViewBlink

It is used in a frame-class:

Code: Select all

class WebFrame : public wxFrame
While it works quite fine by now, I have encountered a difficulty with my app, if it is paused for a long time (or maybe it is the sleep mode of the pc). I use Windows10x64 and have the computer in locked sleep mode over night - the app keeps running.

The next morning I got a null-ptr exception in the evtloop.cpp (see last lines):

Code: Select all

bool wxGUIEventLoop::PreProcessMessage(WXMSG *msg)
{
    HWND hwnd = msg->hwnd;
    wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
    wxWindow *wnd;

    // this might happen if we're in a modeless dialog, or if a wx control has
    // children which themselves were not created by wx (i.e. wxActiveX control children)
    if ( !wndThis )
    {
        while ( hwnd && (::GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD ))
        {
            hwnd = ::GetParent(hwnd);

            // If the control has a wx parent, break and give the parent a chance
            // to process the window message
            wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
            if (wndThis != NULL)
                break;
        }

        if ( !wndThis )
        {
            // this may happen if the event occurred in a standard modeless dialog (the
            // only example of which I know of is the find/replace dialog) - then call
            // IsDialogMessage() to make TAB navigation in it work

            // NOTE: IsDialogMessage() just eats all the messages (i.e. returns true for
            // them) if we call it for the control itself
            return hwnd && ::IsDialogMessage(hwnd, msg) != 0;   // <---- NULL PTR Exception
        }
    }
As you can see in the screenshot, the debugger comes from "node.dll" which is the dll from MiniBlink backend of the webview.
Any ideas how to catch or further debug this? I cant have my app randomly crash and I can't reproduce this behavior either. Putting the pc in energy saving mode doesnt produce it, it needs more time to occur.
The Frame does not need to be shown for this error (at least I am pretty sure it doesn't - will test this over night).

Best Natu
Attachments
Debugging with Microsoft Visual 2015.png
exception Message.png
exception Message.png (10.63 KiB) Viewed 256 times

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2928
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGUIEventLoop Null-Ptr-Exception

Post by ONEEYEMAN » Tue Jan 22, 2019 3:19 pm

Hi,
I presume you didn't have this issue with the pre3vious version of wx?
Do you have the source code for the node.dll?
If not - do you have a means to contact the author?
If not - you are out of luck and need to use some well-known backend. (IE, Mozilla/FF, Chromium)

Thank you.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Wed Jan 23, 2019 7:22 am

Hey
ONEEYEMAN wrote:I presume you didn't have this issue with the pre3vious version of wx?
I didn't. But with the previous version, I didn't even have this webview dialog with blink backend, which is causing the problem. I may have explained myself a bit poorly in that regard.
ONEEYEMAN wrote:Do you have the source code for the node.dll?
If not - do you have a means to contact the author?
It is an open project on GitHub, the node.dll is the compiled code of the MiniBlink project. Unfortunately, it is documented in chinese and I cant read that. Also, I am not able to build MiniBlink myself, because my compiler runs out of heap space after an hour.
ONEEYEMAN wrote:If not - you are out of luck and need to use some well-known backend. (IE, Mozilla/FF, Chromium)
If there was any up to date implementation for Mozilla or Chromium available, I would try that. The MiniBlink project looked so promising, because of the easy implementation and because its wxWidgets implementation is still worked upon.

Thanks for your input. I might need to open an issue on GitHub. Just needed some food for thought, there could have been another way tackeling it from my side.

Thank you.
Best
Natu

User avatar
doublemax
Moderator
Moderator
Posts: 12996
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGUIEventLoop Null-Ptr-Exception

Post by doublemax » Wed Jan 23, 2019 8:57 pm

First you need to find a way to reproduce the issue. If it only happens when the computer goes to sleep, that should be easy to find out.

Also, use the task manager and check the memory and handle usage when your application is running. Maybe there's a leak somewhere.

BTW: I intend to make some experiments with wxWebViewBlink myself, but don't know when that'll be.
Use the source, Luke!

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Thu Jan 24, 2019 7:31 am

Yesterday, the app didn't throw an exception - the frame wasn't shown. But over the night to today, I have the exception again - I made sure the frame was shown before I left.
I am sure it is the msg->hwnd because it's value is NULL and the whole function is build on it. The PreProcessMessage doesn't expect a NULL value in hwnd.
I wonder, if the eventloop rethrows the exception? If so maybe I can try catch it. Or I rethrow it myself, but I dont think that it will be given back into my hands.

Best
Natu

User avatar
doublemax
Moderator
Moderator
Posts: 12996
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGUIEventLoop Null-Ptr-Exception

Post by doublemax » Thu Jan 24, 2019 10:13 am

I am sure it is the msg->hwnd because it's value is NULL and the whole function is build on it. The PreProcessMessage doesn't expect a NULL value in hwnd.
I wouldn't care about this "low level" detail too much. The real problem is probably much further up.

Is wxWebViewBlink actually doing anything at that point, is it displaying a page?

Have you tried building a minimal sample that just contains wxWebViewBlink and checked if that crashes, too?
Use the source, Luke!

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Thu Jan 24, 2019 12:31 pm

doublemax wrote:I wouldn't care about this "low level" detail too much. The real problem is probably much further up.

Is wxWebViewBlink actually doing anything at that point, is it displaying a page?

Have you tried building a minimal sample that just contains wxWebViewBlink and checked if that crashes, too?
Yes, the webview does always show an index.html. Though the shown content is quite minimal, I have not yet tested if it crashes without any content. I will do that the coming night. ;-)
The problem might also be, that the shown content is read from the memory (virtual file system). When the system is entering power saving mode, at some point the RAM is surely dumped...

Best
Natu

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Fri Jan 25, 2019 7:01 am

doublemax wrote:I wouldn't care about this "low level" detail too much. The real problem is probably much further up.

Is wxWebViewBlink actually doing anything at that point, is it displaying a page?

Have you tried building a minimal sample that just contains wxWebViewBlink and checked if that crashes, too?
Yes, the webview does always show an index.html. Though the shown content is quite minimal, I had not tested if it crashes without any content. I did that the last night. When I logged in again, I could see the empty Dialog for a short while before I got the exception. So yes, no content needed for it to crash.

Best
Natu

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Mon Jan 28, 2019 7:15 am

doublemax wrote:BTW: I intend to make some experiments with wxWebViewBlink myself, but don't know when that'll be.
Just a side note: Even with some serious server hardware, the MiniBlink master takes about 3-4h to compile. I learned only after that time, that the master is not always buildable (you can run into heap overflow and after that also into linker errors). So if possible, I would recommend to use the precompiled dll.

Best
Natu

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2928
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGUIEventLoop Null-Ptr-Exception

Post by ONEEYEMAN » Mon Jan 28, 2019 3:49 pm

Hi,
Do they provide debug version of DLL?

BTW, I was able to compile FF on my Gentoo system with just 4G of RAM...

Thank you.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxGUIEventLoop Null-Ptr-Exception

Post by Natulux » Tue Jan 29, 2019 1:20 pm

Hey
ONEEYEMAN wrote:Hi,
Do they provide debug version of DLL?
No, not that I know of. I would have needed the .pdb to debug it with vs and I couldn't get that. I could not use the pecompiled DLL anyway, because the context menu of a right click has hardcoded chinese signs in it.
ONEEYEMAN wrote: BTW, I was able to compile FF on my Gentoo system with just 4G of RAM...
Well, if you know your settings, you can do that. I got quite frustrated, when I learned after 3 hours of compiling, that I could run into barriers like that (and I still don't know how to compile data like that with visual studio). I had the same issue with very large header files (which contained container data made to one big hex string and included as one big char array with like 80MB of text). When those were included, it would not run either due to heap and/or stack overflow.

Since I was able to compile the MiniBlink DLL on the server, I just copied my EXE to the server and attached the DLL with the Debugger of vs2015 to the running process of my EXE. That works quite fine.
Getting any kind of hold on the massive project of the blink backend by just guessing is a whole other adventure...

Best
Natu

Post Reply