[Solved] CEGUI vs DLL vs Executable vs Windows XP

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

[Solved] CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Wed Aug 16, 2017 09:09

Hi,

So i have this very strange but hopefully easy to solve issue for you guys.

I am compiling cegui with vs2015 toolset 140_xp. On windows 10 everything works fine and is peachy, on XP however the static portion of the cegui code wont load correctly when written in a DLL that is loaded on runtime. When i write the same code into an executable, cegui runs just fine.

Here is the produced log for the crash:

16/08/2017 11:08:42 (Std) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16/08/2017 11:08:42 (Std) + Crazy Eddie's GUI System - Event log +
16/08/2017 11:08:42 (Std) + (http://www.cegui.org.uk/) +
16/08/2017 11:08:42 (Std) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

16/08/2017 11:08:42 (Std) CEGUI::Logger singleton created. (00157160)
16/08/2017 11:08:42 (Std)
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std) * Important: *
16/08/2017 11:08:42 (Std) * To get support at the CEGUI forums, you must post _at least_ the section *
16/08/2017 11:08:42 (Std) * of this log file indicated below. Failure to do this will result in no *
16/08/2017 11:08:42 (Std) * support being given; please do not waste our time. *
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std) * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std) ---- Version: 0.8.7 (Build: Jul 18 2017 Static Microsoft Windows MSVC++ 14.0 (2015) 32 bit) ----
16/08/2017 11:08:42 (Std) ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
16/08/2017 11:08:42 (Std) ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
16/08/2017 11:08:42 (Std) ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
16/08/2017 11:08:42 (Std) ---- Scripting module is: None ----
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std) * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
16/08/2017 11:08:42 (Std) ********************************************************************************
16/08/2017 11:08:42 (Std)
16/08/2017 11:08:42 (Std) ---- Begining CEGUI System initialisation ----
16/08/2017 11:08:42 (Std) [CEGUI::ImageManager] Singleton created (0024C058)
16/08/2017 11:08:42 (Std) [CEGUI::ImageManager] Registered Image type: BasicImage
16/08/2017 11:08:42 (Std) CEGUI::FontManager singleton created. (0024B7F8)
16/08/2017 11:08:42 (Std) CEGUI::WindowFactoryManager singleton created
16/08/2017 11:08:42 (Std) CEGUI::WindowManager singleton created (02456040)
16/08/2017 11:08:42 (Std) CEGUI::SchemeManager singleton created. (0327DD78)
16/08/2017 11:08:42 (Std) CEGUI::GlobalEventSet singleton created. (0024FFD0)
16/08/2017 11:08:42 (Std) CEGUI::AnimationManager singleton created (0024F068)
16/08/2017 11:08:42 (Std) CEGUI::WidgetLookManager singleton created. (001E1B40)
16/08/2017 11:08:42 (Std) CEGUI::WindowRendererManager singleton created (0024FFF0)
16/08/2017 11:08:42 (Std) CEGUI::RenderEffectManager singleton created (02455CF0)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'DefaultWindow' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'DefaultWindow' windows added. (0245BED0)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'DragContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'DragContainer' windows added. (0245C260)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'ScrolledContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'ScrolledContainer' windows added. (0245C3C0)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'ClippedContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'ClippedContainer' windows added. (0245C720)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/PushButton' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/PushButton' windows added. (0245C938)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/RadioButton' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/RadioButton' windows added. (0245CA98)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Combobox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Combobox' windows added. (0245CB40)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ComboDropList' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ComboDropList' windows added. (0245CDA0)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Editbox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Editbox' windows added. (0245CFC8)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/FrameWindow' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/FrameWindow' windows added. (0245D070)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ItemEntry' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ItemEntry' windows added. (0245D480)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Listbox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Listbox' windows added. (0245D698)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ListHeader' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ListHeader' windows added. (0245D740)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ListHeaderSegment' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ListHeaderSegment' windows added. (0245D958)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Menubar' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Menubar' windows added. (0245DC68)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/PopupMenu' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/PopupMenu' windows added. (0245DD10)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/MenuItem' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/MenuItem' windows added. (0245DE70)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/MultiColumnList' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/MultiColumnList' windows added. (0245DF18)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/MultiLineEditbox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/MultiLineEditbox' windows added. (0245E078)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ProgressBar' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ProgressBar' windows added. (0245E1D8)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ScrollablePane' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ScrollablePane' windows added. (0245E338)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Scrollbar' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Scrollbar' windows added. (0245E498)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Slider' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Slider' windows added. (0245E540)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Spinner' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Spinner' windows added. (0245E758)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/TabButton' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/TabButton' windows added. (0245E800)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/TabControl' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/TabControl' windows added. (0245EAD0)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Thumb' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Thumb' windows added. (0245EC30)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Titlebar' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Titlebar' windows added. (0245ECD8)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ToggleButton' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ToggleButton' windows added. (0245ED80)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Tooltip' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Tooltip' windows added. (0245EF98)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/ItemListbox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/ItemListbox' windows added. (0245F1A8)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/GroupBox' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/GroupBox' windows added. (0245F308)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'CEGUI/Tree' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'CEGUI/Tree' windows added. (0245F468)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'LayoutCell' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'LayoutCell' windows added. (0245F5C8)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'HorizontalLayoutContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'HorizontalLayoutContainer' windows added. (0245F728)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'VerticalLayoutContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'VerticalLayoutContainer' windows added. (0245F988)
16/08/2017 11:08:42 (Std) Created WindowFactory for 'GridLayoutContainer' windows.
16/08/2017 11:08:42 (Std) WindowFactory for 'GridLayoutContainer' windows added. (0245FC58)
16/08/2017 11:08:42 (Std) CEGUI::System singleton created. (00153158)
16/08/2017 11:08:42 (Std) ---- CEGUI System initialisation completed ----
16/08/2017 11:08:42 (Std)
16/08/2017 11:08:43 (Std) Started creation of Scheme from XML specification:
16/08/2017 11:08:43 (Std) ---- CEGUI GUIScheme name: TaharezLook
16/08/2017 11:08:43 (Std) [ImageManager] Started creation of Imageset from XML specification:
16/08/2017 11:08:43 (Std) [ImageManager] ---- CEGUI Imageset name: TaharezLook
16/08/2017 11:08:43 (Std) [ImageManager] ---- Source texture file: TaharezLook.png
16/08/2017 11:08:43 (Std) [ImageManager] ---- Source texture resource group: (Default)
16/08/2017 11:08:43 (Std) [Direct3D9Renderer] Created texture: TaharezLook
16/08/2017 11:08:43 (Error) CEGUI::UnknownObjectException in function 'class CEGUI::Image &__thiscall CEGUI::ImageManager::create(const class CEGUI::XMLAttributes &)' (cegui\cegui\src\ImageManager.cpp:190) : Unknown Image type:
16/08/2017 11:08:43 (Error) The last thrown exception was related to XML file 'TaharezLook.imageset' from resource group 'imagesets'.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Thu Aug 17, 2017 19:31

Interesting.

What do you mean by static CEGUi code? Can you give an example so I can understand?

And the CEGUI exception is always triggered while parsing the taharezlook imageset?
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Fri Aug 18, 2017 12:29

so, this was a tricky one. This is actually vs2015 related! The way that CEGUI works with STATIC function scope variables is not supported < VISTA.
Thread Local Storage variables wont get initialized properly. Now with vs2015 MS introduced threadSafeInit as a compiler flag and set to to enabled by default.

This will make any static / debug dll or even statically linked dll not initialize the variables. If you compile with vs2015 and platform toolset vs140_xp PLUS set the extra compiler option : Zc:threadSafeInit- (the "-" is important as it disables the option) your cegui UI will show up on XP as well.

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Fri Aug 18, 2017 12:31

as an example:

Code: Select all

static const String type_default("BasicImage");
   
    const String& type(attributes.getValueAsString(ImageTypeAttribute, type_default));
    const String& name(attributes.getValueAsString(ImageNameAttribute));


will not work on windows xp without the threadSafeInit flag (in DLLs)

More on the topic: https://docs.microsoft.com/en-us/cpp/bu ... ialization

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Sat Aug 19, 2017 10:10

I just researched it a bit and this seems to be a pre-C++11 problem.

I must add that we never really tested CEGUI usage across threads, CEGUI is typically used in one thread. So we never came across this so far and afaik this is the first report. This would however probably also hit a lot of other libraries and frameworks out there, having function-scope static vars is not really something fancy in my opinion, but something quite normal to have.

The good news on this topic is:
Starting in C++11, scoped static initialization is now thread-safe

which also mentions the downside of it

More info:
https://blogs.msdn.microsoft.com/oldnew ... 0/?p=40363

In the end I would just recommend to run CEGUi only in its own thread, that should solve this also on VS 2015, if i m not mistaken.
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Sat Aug 19, 2017 10:38

Hmm, so we are not using multiple threads actually. The game runs within on thread only and the thread also loads the library.

We do have one worker thread running to remove hooks we placed tho. I do not see how this is related tho.

Thanks for checking into that man, appreciate it. I'll spend more time over the weekend to dig a little deeper and will let you know about the thread issue.

Can you share your reasoning for the local statics in cegui? Did you want to easen memory cleanups? I am wondering why you guys went all in on references rather than pointers.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Sat Aug 19, 2017 11:02

uvhannes wrote:Hmm, so we are not using multiple threads actually. The game runs within on thread only and the thread also loads the library.

In that case I dont see at all how the threadsafeinit flag can possibly be related and can possibly fix your issue. Function-scope statics are perfectly legal, well-defined, and were used in almost every project I have ever participated.

uvhannes wrote:Thanks for checking into that man, appreciate it. I'll spend more time over the weekend to dig a little deeper and will let you know about the thread issue.

Yes, it would be good to know more about this.

uvhannes wrote:Can you share your reasoning for the local statics in cegui? Did you want to easen memory cleanups?

I have nothing against turning the simple local constant variables into regular constants without static. Feel free to make a PR for this if you want to make this change, it should be fairly simple to search through the code and replace, but clearly it is a bit of a tedious work. There is of course complex types which we don't wanna instantiate on every function call, in that case we would want to have them static. It's to be questioned if String is such a type. If a function is called hundreds of times per frame, then instantiating a String, which might require an Unicode conversion in CEGUI, might make a slight performance difference that justifies making it static. Maybe having those as class static consts is a possibility.

uvhannes wrote:I am wondering why you guys went all in on references rather than pointers.

This is more of a philosophical question. I think this also doesn't really belong to the rest of the topic or am I missing something? But to answer your question: I did not make the decision but i think the reasoning was that a reference implies that the value cannot be null (of course you can still go out of your way to fuck things up and make a ref to null... but if somebody wants to blow their code up on purpose that's their own fault and business), whereas a pointer might be used to be able to determine if a call was successul and requires null-checks.

What's the issue with references anyways?
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Sat Aug 19, 2017 18:19

appreciate them answers, Ident :)

In that case I dont see at all how the threadsafeinit flag can possibly be related and can possibly fix your issue. Function-scope statics are perfectly legal, well-defined, and were used in almost every project I have ever participated.


This might be true, but not for DLLs on windows XP apparently.

This is more of a philosophical question.


Agreed on that :)

cheers man, as i said, thanks for them answers, this is greatly appreciated :)

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Sat Aug 19, 2017 19:59

uvhannes wrote:This might be true, but not for DLLs on windows XP apparently.

That would be odd though. I am sure CEGUI was more used during XP times than it is now and I never had issues (back then using XP myself) nor did we get any reports. Could it be that you use any non-default flags? Is it maybe a bug in a specific version of VS2015? Maybe it just works in VS2013 and below which is why we didnt get reports, and VS2015 just has this messed up - but then again why didnt we come across that while searching for the general issue.

cheers man, as i said, thanks for them answers, this is greatly appreciated :)

You are welcome. Please also give us feedback if you think another approach is better.
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Sat Aug 19, 2017 20:11

That would be odd though. I am sure CEGUI was more used during XP times than it is now and I never had issues (back then using XP myself) nor did we get any reports. Could it be that you use any non-default flags? Is it maybe a bug in a specific version of VS2015? Maybe it just works in VS2013 and below which is why we didnt get reports, and VS2015 just has this messed up - but then again why didnt we come across that while searching for the general issue.


This thread safe init behaviour was enabled by default only in vs2015. Any vs before that wont have the issue. (i have tested every vs back to 2010)

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Sat Aug 19, 2017 20:19

uvhannes wrote:
That would be odd though. I am sure CEGUI was more used during XP times than it is now and I never had issues (back then using XP myself) nor did we get any reports. Could it be that you use any non-default flags? Is it maybe a bug in a specific version of VS2015? Maybe it just works in VS2013 and below which is why we didnt get reports, and VS2015 just has this messed up - but then again why didnt we come across that while searching for the general issue.


This thread safe init behaviour was enabled by default only in vs2015. Any vs before that wont have the issue. (i have tested every vs back to 2010)


Ok that's very interesting. I still find it extremely likely though that it would mess with other projects as well and thus it is odd it would be there. Are you sure there is no other project settign on VS 2015 that you might have changed for it , which could have in the end caused a problem combined with that threadsafeinit flag?

See for example https://stackoverflow.com/questions/366 ... is-warning
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Sat Aug 19, 2017 20:57

my test DLL is a fresh created DLL with
<Keyword>Win32Proj</Keyword>


i am indeed linking against the v140_xp toolset tho. Other than that, this is all very much standard vs2015 settings :/

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby Ident » Sat Aug 19, 2017 21:41

Ok that's odd then. Really odd. And not much we can do unfortunately.
CrazyEddie: "I don't like GUIs"

uvhannes
Just popping in
Just popping in
Posts: 10
Joined: Wed Aug 16, 2017 09:01

Re: CEGUI vs DLL vs Executable vs Windows XP

Postby uvhannes » Sat Aug 19, 2017 23:18

I do not believe you guys have to do something here. It all is smooth and peachy when making sure the threadsafe init feature is not turned on by default :)

MS did the change for a reason, and frankly, i like the change. CEGUI was developed against the non thread safe version, so i believe its safe to have it disabled for the CEGUI dlls.

Ill keep the feature enabled on our DLLs. You can flag this thread as solved, as far as i am concerned ;)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 26 guests