BJanusz BJanusz - 28 days ago 13
C++ Question

Wt c++ critical error when creating WApplication object

I have problem with my Wt web application. It's rather simple app, I do not need to deploy it on any external server (only localhost), so built in whttpd server provided by framework is sufficient for my needs. I create an executable file in release mode (Visual Studio 2015), run it, and when I open localhost:8080 in browser to access application, I get an error. In debug mode however everything works well.

Debug console shows this:


Exception thrown at 0x00007FFB08477788 in
Neural_network_visualisation.exe: Microsoft C++ exception:
std::runtime_error at memory location 0x00000025E30FB408.

Critical error detected c0000374

Neural_network_visualisation.exe has triggered a breakpoint.


main.cpp

#include "MyApplication.h"
#include "MyContainerWidget.h"

WApplication *createApplication(const WEnvironment& env) //exception is thrown here
{
Wt::WApplication *app = new Wt::WApplication(env); //error c0000374
app->setCssTheme("polished");
new MyContainerWidget(app->root());

return app;
}

int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}


The exception is thrown just after entering createApplication function, but the program doesn't crash there. After executing first line critical error is shown and application stops.

The code is so simple that I can't see any problem with it. My guess is that release mode expects some special configuration to work with Wt, but official documentation doesn't mention anything more is needed while using built-in http server. Can anybody with Wt experience help me with this?

Edit 1:

I changed my code so it looks like this:

#include "MyApplication.h"
#include "MyContainerWidget.h"

WApplication *createApplication(const WEnvironment& env)
{
//Wt::WApplication *app =
// app->setCssTheme("polished");
//new MyContainerWidget(app->root());

return new Wt::WApplication(env);;
}

int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}


Now the error is different and states:


HEAP[Neural_network_visualisation.exe]: Invalid address specified to
RtlValidateHeap( 000002A04F550000, 000002A05117F060 )


So this is a memory management problem. In debug mode this management works quite different than in release, that's why I do not get any error while in debug. Unfortunately, I still do not know how to fix this. Any ideas?

Answer

Problem solved. I still can't exactly tell what was the cause, but I recompiled Wt and Boost libraries and changed project properties to match with the Wt examples. I also had to change build type from x64 to x86. It works now.