installModule() crashes if Module Manager not open

Bug #1537906 reported by Vadim Peretokin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mudlet
Fix Released
Medium
Stephen Lyons

Bug Description

I'm getting this crash using latest release_30 branch (5dcf32ab3a7f780e2a439e8d5abb35e932350c82) code when trying to run the following only when the module manager window is not open:

lua installModule([[/home/vadi/Games/Mudlet/svof/svo (burncounter).xml]])

Thread 1 (Thread 0x7ffff7f9d7c0 (LWP 12723)):
#0 0x000000000046ac24 in QWidget::testAttribute (this=0xf60324, attribute=Qt::WA_WState_Visible) at /usr/include/qt5/QtWidgets/qwidget.h:859
No locals.
#1 0x000000000046abfb in QWidget::isVisible (this=0xf60324) at /usr/include/qt5/QtWidgets/qwidget.h:821
No locals.
#2 0x00000000005a0351 in mudlet::moduleTableVisible (this=0xec9ca0) at mudlet.cpp:416
No locals.
#3 0x000000000065f2df in TLuaInterpreter::installModule (L=0x1d2c250) at TLuaInterpreter.cpp:11037
        modName = {static npos = <optimised out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x2f34db8 "/home/vadi/Games/Mudlet/svof/svo (burncounter).xml"}}
        pHost = 0x1ce4b60
        module = {static null = {<No data fields>}, d = 0x2f18c40}
#4 0x00007ffff797af78 in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.

If I open the module manager window, the command runs fine.

summary: - Crash using installModule
+ installModule() crashes if Module Manager not open
Revision history for this message
Stephen Lyons (slysven) wrote :

The function concerned is:

int TLuaInterpreter::installModule( lua_State * L)
{
    string modName;
    if ( ! lua_isstring( L, 1 ) )
    {
        lua_pushstring( L, "installModule: wrong first argument (should be a path to module)");
        lua_error( L );
        return 1;
    }
    else
        modName = lua_tostring( L, 1);
    Host * pHost = TLuaInterpreter::luaInterpreterMap[L];
    QString module = QDir::fromNativeSeparators(modName.c_str());
    if( pHost )
        if ( pHost->installPackage( module, 3 ) && mudlet::self()->moduleTableVisible() )
            mudlet::self()->layoutModules();
    return 0;
}

The conversion from the supplied argument has not been Utf8-ified (yet) but that is not important, neither is is the conversion from native file separators IMHO. I think the test for `mudlet::self()->moduleTableVisible()` SHOULD BE BEFORE `pHost->installPackage( module, 3 )` - the evaluation order is wrong!

BTW what about the case where there is more than one profile active and the module manager window is open FOR THE OTHER PROFILE? I think we may have issues with that sort of thing where there is a resource that is shared between all the profiles but each profile thinks it can use the common resource without checking that it is the "active" profile...

Revision history for this message
Stephen Lyons (slysven) wrote :

Ah, misread the function of that "if" - it is supposed to install the package AND IF the module widget is present THEN it is refreshed to reflect the change - so that ISN'T the problem... *sigh*

Revision history for this message
Vadim Peretokin (vperetokin) wrote : Re: [Bug 1537906] Re: installModule() crashes if Module Manager not open

Right - the crash is within the moduleTableVisible() function itself,
specifically when it calls isVisible().

On Tue, Jan 26, 2016 at 8:25 AM Stephen Lyons <email address hidden>
wrote:

> Ah, misread the function of that "if" - it is supposed to install the
> package AND IF the module widget is present THEN it is refreshed to
> reflect the change - so that ISN'T the problem... *sigh*
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1537906
>
> Title:
> installModule() crashes if Module Manager not open
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mudlet/+bug/1537906/+subscriptions
>

Revision history for this message
Stephen Lyons (slysven) wrote :

I wonder how the details of the module widget is stored - perhaps a pointer that is not initialised to zero before the widget is instantiated - let me go and look...

Revision history for this message
Stephen Lyons (slysven) wrote :

Ah yeah - got it, the moduleTableVisible() call does not check that the (QTableWidget *)mudlet::moduleTable point is valid (and that pointer is not zeroed by an initialisation list in the mudlet class constructor anyhow). Workings on it now!

Stephen Lyons (slysven)
Changed in mudlet:
status: New → Confirmed
assignee: nobody → Stephen Lyons (slysven)
status: Confirmed → In Progress
Revision history for this message
Stephen Lyons (slysven) wrote :

Fix pulled into development (https://github.com/Mudlet/Mudlet/pull/291) AND release_30 branches (https://github.com/Mudlet/Mudlet/pull/292)!

Changed in mudlet:
status: In Progress → Fix Committed
Changed in mudlet:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.