Project

General

Profile

Wt crash !

Added by Christophe Delépine over 14 years ago

Hello,

Wt crashes in Release (ok in Debug) during session initialization (the web server is correctly launched but when a session is opened, it crashes)

The crash is 100% repeatable. (see callstack in attached file).

My Wt application is empty, so the crash is not related to widgets :

HelloApplication::HelloApplication(const WEnvironment& env)

: WApplication(env)

{

}

I have tried Wt3.1.3 and Wt3.1.4 and both crash.

I have tried multithreaded and non multithreaded Wt builds and both crash

I think the problem comes from the fact that my Wt application resides in a DLL (plugin) that is loaded by my executable's main with LoadLibrary.

If i move the Wt code into the executable's main (just like in the provided examples), then it does not crash.

The problem seems related with STL iterators in the boost signals library.

In my case Wt is statically linked with boost (i have not tried with dynamic libraries)

Any help would be greatly appreciated since i have no clue of what is going on.

Moving my code to the main is not a solution for me, i need the Wt code to remain in a plugin DLL.

Regards

Christophe


Replies (5)

RE: Wt crash ! - Added by Wim Dumon over 14 years ago

Hello Christophe,

My number 1 suspect is a problem with mixing runtime libraries in MSVC, especially when there is some form of interaction between the DLL and the exe (passing objects between one and the other, one frees memory that the other one allocated, ...). MSVC doesn't allow any mixing at all: static/dynamic and debug/release must be identical for all dlls in your app. Your exe and the dll must be compiled with the same version of MSVC (2005 I presume, from the looks of your stack trace), and the CRT compiler switch (/MT, /MTd, /MD, /MDd) must be identical for all projects. There's a few things you should check with respect to this:

  • Watch for warnings while linking your .dll and .exe
  • Can you use the Depends.Exe tool that comes with your compiler to open the DLL (containing the Wt application) and the EXE (which loads the application), and look if there is more than one version of msvcrt loaded?
  • Verify that all your project's /M[TD](d) options are identical
  • Watch the list of loaded modules for hints of different versions being used in your program

If all your runtime libraries are right, could you try to load your Wt DLL from a minimal .cpp program and see if it works?

Oh and don't forget to remove your build directory completely and rebuild from scratch, as it wouldn't be the first time that MSVC fails to get all of its dependencies right.

It is not a special case to load a complete Wt application as a DLL, as that is exactly what happens in the ISAPI connector. I don't know how you built your DLL (using cmake or your own build files) - maybe our examples/CMakeLists.txt could hint you in the correct direction?

Regards,

Wim.

RE: Wt crash ! - Added by Christophe Delépine over 14 years ago

Hello Wim,

I have noticed that the crash disappears if i remove those lines from my .h :

#include <Wt/WApplication>
//#include <Wt/WSignalMapper>  <-- REMOVED

class HelloApplication : public Wt::WApplication
{
public:
    HelloApplication(const Wt::WEnvironment& env);
    ~HelloApplication();

private:

    //Wt::WSignalMapper< std::string >* expandButtonMapper_; <-- REMOVED
};

Do you think it is a clue ?

Regards

Christophe

P.S I will check my compilation settings as you suggested.

RE: Wt crash ! - Added by Wim Dumon over 14 years ago

Hey Christophe,

Maybe a misbuild? Did you remove your build directory completely as I suggested?

BR,

Wim.

RE: Wt crash ! - Added by Christophe Delépine over 14 years ago

Another clue :

I have _SECURE_SCL=0 in my preprocessor definitions for my plugin's project but Wt and Boost have been compiled without this setting (on by default)

If i remove _SECURE_SCL=0 from my plugin's project settings then the crash disappears.

I will try to recompile Wt and Boost with this setting and see if it works when i put that setting back again in my project.

I imagine the setting must be consistent in all projects ?

Regards

Christophe

RE: Wt crash ! - Added by Christophe Delépine over 14 years ago

OK i confirm that _SECURE_SCL was the cause of the crash.

I have recompiled Boost and Wt with "_SECURE_SCL=0" and now it works. This flag must be consistent in all projects.

Sorry about that, that was my fault..

Regards

Christophe

    (1-5/5)