Page 1 of 2

segfaults with notifyDisplaySizeChanged

Posted: Mon Apr 25, 2016 06:25
by mobarre
Disclaimer: bear with me, I'm new to CEGUI. If additional info is needed, I'll be happy to provide anything.

I've started a little project that makes use of some very classic bricks: Ogre, OIS, CEGUI and Bullet. So far things go great, I'm fixing one little thing after the other. I got to the point where I need to fix the behavior of my app when resizing the window. Naturally, I turned to notifyDisplayChanged to do most of the job on the CEGUI side. I use it inside my windowResized event in my WindowEventListener.

Code: Select all

void WindowEventListener::windowResized (Ogre::RenderWindow* rw)
  {
    unsigned int width, height, depth;
    int left, top;
    rw->getMetrics (width, height, depth, left, top);

    const OIS::MouseState &ms = Application::getSingleton().getMouse()->getMouseState();
    ms.width = width;
    ms.height = height;
    //Notify CEGUI of the window size change
    CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Sizef(static_cast <float>(width), static_cast <float>(height)));
  }


This code results in a segfault at the time of the execution of CEGUI::System::ImageManager::notifyDisplaySizeChanged.

Code: Select all

21/04/2016 09:44:35 (Std)   ---- Version: 0.8.5 (Build: Apr 20 2016 GNU/Linux g++ 5.3.0 64 bit) ----
21/04/2016 09:44:35 (Std)   ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
21/04/2016 09:44:35 (Std)   ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
21/04/2016 09:44:35 (Std)   ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
21/04/2016 09:44:35 (Std)   ---- Scripting module is: None ----


Stack trace http://pastebin.com/rBny3brz

If there's any info I can provide to help, I'd be happy to. Would it be worth building a debug build of CEGUI and link against it ? Do you guys want the full cegui log file ?

Cheers,
Marc.

Re: segfaults with notifyDisplaySizeChanged

Posted: Mon Apr 25, 2016 11:43
by YaronCT
marc: I need more information. Plz post full cegui log. If possible, plz also a piece of cegui code that leads to the problem (containing all cegui related code, not just the specific command that leads to the problem). If that's not possible, plz upload your whole project somewhere and give us a user scenario that leads to the problem.

Re: segfaults with notifyDisplaySizeChanged

Posted: Mon Apr 25, 2016 11:55
by lucebac
What OGRE version are you using? CEGUI's ImageManager uses OGRE's built-in one, so that might cause the problem.

Re: segfaults with notifyDisplaySizeChanged

Posted: Mon Apr 25, 2016 15:47
by mobarre
Hi there !

Thanks for the quick feed back. I'm using Ogre 1.9.0 from the archlinux repo.

Here's a copy of the full CEGUI logs: http://pastebin.com/Acms16dh

Important note: The above log are from a run that did not crash (I commented out the call to notifyDisplaySizeChanged). Not ideal, but when the program segfaults, it appears that CEGUI doesn't write any logs. At least not on its own. I'll see if I can get it to flush before crashing (maybe in a try-catch ?)
If you guys have suggestions for that, I'm listening :)

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 06:41
by YaronCT
mobarre: Can u plz upload your whole project somewhere?

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 11:41
by mobarre
@yaronct: I can give you access on github if you have an account. For now the repo is a private one.

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 13:22
by YaronCT
mobarre: I do, my username is "yaronct".

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 14:32
by mobarre
Hey,

Just gave you read access. The branch you want to look at is the "Mouse_accuracy" one.

It's a codeblocks project, I hope that's not going to be an issue for you... But at least you get to take a look at the code.

The call to notifyDisplaySizeChanged is in WindowEventListener.cpp, where the windowResized event is implemented.

Cheers,
Marc.

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 15:03
by mobarre
CEGUI 0.8.6 is out on archlinux. To make sure that I'm all good, I've upgraded and also made sure that my version of ogre is indeed the archlinux stock 1.9.0.

Crash is still there, but this rules out me playing with custom built packages :)

Re: segfaults with notifyDisplaySizeChanged

Posted: Tue Apr 26, 2016 19:48
by YaronCT
Thanx I'll give it a look. I can install codeblocks, no problem.

Yeah I notifed the Arch linux guy about the release, seems like he's already updated the package. Too bad coz 0.8.7 is to be released today :lol:

Re: segfaults with notifyDisplaySizeChanged

Posted: Wed Apr 27, 2016 11:32
by YaronCT
mobarre: Ok good news, I'm able to run the program. Now what should I do to get the problem?

Re: segfaults with notifyDisplaySizeChanged

Posted: Wed Apr 27, 2016 12:50
by lucebac
You need to resize your window when the application is running. That should cause the crash he described.

Re: segfaults with notifyDisplaySizeChanged

Posted: Wed Apr 27, 2016 15:17
by mobarre
Hmm, Just saw the last messages.

The app should actually crash when the window gets displayed (the resize event gets called on window creation as far as I can see). If it's not crashing for you, it might be a library issue on my side. Which means I might need to get in touch with the archlinux CEGUI maintainer.

What distro are you using ?

Re: segfaults with notifyDisplaySizeChanged

Posted: Wed Apr 27, 2016 15:44
by YaronCT
mobarre: I'm using Debian 8 x64 with the official Bullet (2.82), and I've built myself OGRE 1.9.0 and CEGUI 0.8.6. I'd leave the Arch maintainer alone for now, 1st plz try building CEGUI and OGRE yourself (the default CMake options plus "-DCMAKE_BUILD_TYPE=Debug" should do I think, so it should b pretty straightforward).

I didn't use codeblocks but built your project using CMake. I just added a "CMakeLists.txt" file at the top level directory of your project with the following conteint:

Code: Select all

cmake_minimum_required(VERSION 3.0)
project( SpaceFuckery LANGUAGES C CXX )

set( CMAKE_PREFIX_PATH /usr/local/ogre/v1_9_0 ${CMAKE_PREFIX_PATH} )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++14" )

set( CMAKE_MODULE_PATH /usr/local/ogre/v1_9_0/lib/OGRE/cmake ${CMAKE_MODULE_PATH} )

find_package( OGRE )
find_package( OIS )
find_package( Bullet )

set( ceguiDir "/usr/local/cegui/v0_8_6" )
set( CEGUI_INCLUDE_DIRS "${ceguiDir}/include/cegui-0" )
set( CEGUI_LIBRARIES "${ceguiDir}/lib/libCEGUIBase-0.so" "${ceguiDir}/lib/cegui-0.8/libCEGUICoreWindowRendererSet.so" "${ceguiDir}/lib/libCEGUIOgreRenderer-0.so" )

add_executable( SpaceFuckery SpaceFuckery/Application.cpp
                  SpaceFuckery/KeyListener.cpp
                  SpaceFuckery/MouseListener.cpp
                  SpaceFuckery/WindowEventListener.cpp
                  SpaceFuckery/FrameListener.cpp
                  SpaceFuckery/main.cpp
                  SpaceFuckery/physicsEngine.cpp )

target_include_directories( SpaceFuckery PRIVATE ${OGRE_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS} ${CEGUI_INCLUDE_DIRS} ${BULLET_INCLUDE_DIRS} )
target_link_libraries( SpaceFuckery PRIVATE ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_LIBRARIES} ${BULLET_LIBRARIES} )


(u might need to adjust the paths to use it yourself). And again, just ran CMake with "-DCMAKE_BUILD_TYPE=Debug".

Plz try to do as I did and c if it helps; there might be issues here like difference between Debug and Release, or some problematic patches applied by Arch.

Re: segfaults with notifyDisplaySizeChanged

Posted: Wed Apr 27, 2016 15:57
by mobarre
Indeed, makes sense.

I'll get on that right away and tell you how it goes.