Menu

#1252 The cbWorkspace class is broken as IsOK() can a bad result

Undefined
invalid
nobody
None
Bug_Report
2022-09-15
2022-04-10
No

The IsOk() comment is:

        /** @brief Was this workspace loaded successfully?
          *
          * @return True if the workspace was loaded successfully, false if not.
          * @note Because the only way to load a workspace is through its
          * constructor, and because we don't use exceptions, this is the only
          * way to know if loading succeeded.
          */
        virtual bool IsOK() const { return m_IsOK; }

But if you look in projectmanager.cpp for the following function:

cbWorkspace* ProjectManager::GetWorkspace()
{
    if (!m_pWorkspace)
    {
        m_pWorkspace = new cbWorkspace(_T(""));
        m_pWorkspace->SetTitle(_("Workspace"));
        m_pWorkspace->SetModified(false);
    }
    return m_pWorkspace;
}

Which is called in compilergcc.cpp where m_pWorkspace is null will result in the IsOk() being true as the cbWorkspace::cbWorkspace constructor does not call Load() as the filename is empty
therefore does not set the m_IsOK to false!!!!

I will not be fixing this as it does not affect the GDB/MI debugger. I found this when trying speed up the compiler.gcc target build process.

Discussion

  • bluehazzard

    bluehazzard - 2022-06-05

    Have you found out what the implications are when m_isOk is wrong?
    I mean, how did you found this out?

     
  • Andrew Cottrell

    Andrew Cottrell - 2022-06-05

    I found this when trying speed up the compiler.gcc target build process.

    I was looking at the state machine that drives the compilation process when adding support for ticket 1253 and extra debug logging so I could see what was happening and found this while learning how the state machine worked.

    The implication with this was that the state machine and code malfunctioned in certain conditions, but I cannot remember as it was 2 months ago.

     
  • Miguel Gimenez

    Miguel Gimenez - 2022-09-15
    • status: open --> invalid
     
  • Miguel Gimenez

    Miguel Gimenez - 2022-09-15

    If the file name is empty then a default and valid workspace is created, so m_IsOk must be true.

     

Log in to post a comment.