[fixed] CGUIEditBox - selecting text causing segfault

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.

[fixed] CGUIEditBox - selecting text causing segfault

Postby ceyron » Tue Dec 14, 2010 12:56 pm

[UPDATE]
Just tried it on windows and it works fine, seems to be only crashing on linux...but why :shock:

When selecting a text in the edit box it will, sometimes(everytime if the edit box has a large text into it) cause the application to crash.
Here is a test case (try selecting the text in the edit box all the way to the end):

Code: Select all
//Irrlicht version: 1.7.2
//OS: linux

#include <cstdlib>
#include <irrlicht.h>

using namespace std;
using namespace irr;
using namespace gui;
using namespace scene;
using namespace video;

/*
 *
 */
int main(int argc, char** argv)
{
    IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32> (800, 600), 32, false, false, false);

    if (!device)
        return EXIT_FAILURE;

    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

    gui::IGUIEditBox* e1 = guienv->addEditBox(L"", core::rect<s32>(50,150,250,240),true);
    e1->setText(L"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
                          "Aliquam venenatis leo vitae lorem tristique non congue felis blandit.\n"
                          "Aliquam et libero sapien. Nullam a adipiscing nunc");
    e1->setAutoScroll(true);
    e1->setMultiLine(true);
    //e1->setMax(1024);

 while (device->run())
    {
        driver->beginScene(true, true, video::SColor(0xFFA0A0A0));

        smgr->drawAll();
        guienv->drawAll();

        driver->endScene();
    }

    return EXIT_SUCCESS;
}


Here's what i get in the terminal, so it's crashing in irrString.h on line 330
Code: Select all
TestEditbox: ../../include/irrString.h:330: T& irr::core::string<T, TAlloc>::operator[](irr::u32) [with T = wchar_t, TAlloc = irr::core::irrAllocator<wchar_t>]: Assertion `!(index>=used)' failed.
Aborted
Press [Enter] to close the terminal ...
Image
User avatar
ceyron
 
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România

Postby hybrid » Tue Dec 14, 2010 1:52 pm

What about the strack trace? Can you see which methods are called in between?
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby ceyron » Tue Dec 14, 2010 2:39 pm

This is what NetBeans shows in call stack
Image
Image
User avatar
ceyron
 
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România

Postby ceyron » Tue Dec 14, 2010 3:40 pm

OK i included irrlicht source directory and copied both CGUIEditbox.h & CGUIEditbox.cpp into my project folder the only lines that i changed from the code posted above are
Code: Select all
#include "CGUIEditBox.h" //after #include <irrlicht.h>

//and creating the element like this
 gui::IGUIEditBox* e1 = new gui::CGUIEditBox(L"",true,guienv,guienv->getRootGUIElement(),-1, core::rect<s32>(50,150,250,240));


...and surprisingly it works, so i thought maybe i linked against another version of irrlicht but i didn't, i rebuild irrlicht and tested again but edit box only works when i do like i mentioned, i have no idea what's going on!

Can someone else running linux test this please...
Image
User avatar
ceyron
 
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România

Postby hybrid » Tue Dec 14, 2010 3:48 pm

Ok, this is the cursor draw code. Since the underflow is tested, it seems that the cursor position is either too large, or the text string is broken. Couldn't test it live for now, but will do so.
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby CuteAlien » Tue Dec 14, 2010 8:26 pm

Should I take this one? Crashes only with mouse-selection. It looks like getCharacterFromPos in getCursorPos shouldn't take Text, but probably txtLine.

edit: Hm, that is the problem, but there is something else strange going on. The \n seems to be replaced by a space character...
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5364
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby hybrid » Tue Dec 14, 2010 9:33 pm

Maybe this happens in order to make our own line breaks instead of user forced ones? And yeah, you can have it. I suck at GUI :wink:
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby CuteAlien » Tue Dec 14, 2010 10:30 pm

Ok, I fixed the crash in svn releases 1.7 branch. Thanks for test-case.

The other problem is independent, I was just confused because it also looked like a selection problem at first. I put that one on my todo for another evening.
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5364
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby ceyron » Wed Dec 15, 2010 9:00 am

Works now, thank you for fixing it
Image
User avatar
ceyron
 
Posts: 63
Joined: Tue Mar 03, 2009 5:10 pm
Location: Bucuresti, România


Return to Bug reports

Who is online

Users browsing this forum: No registered users and 1 guest