News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Crash on CB termination svn 7737

Started by Pecan, February 01, 2012, 07:07:49 PM

Previous topic - Next topic

Pecan

In cbproject.cpp, if the line "delete f;" occurs before the line "m_FileArray.Remove(*it);" CB crashes on termination.

If the "delete f;" follows after the "Remove", crashes disappear.

Current SVN code:

if (f)
{
Manager::Get()->GetEditorManager()->Close(f->file.GetFullPath(),true);
delete f;
}
m_Files.erase(it);
m_FileArray.Remove(*it);
it = m_Files.begin();
}
Manager::Get()->GetEditorManager()->ShowNotebook();


It might be that wxArray.Remove(item&) is actually referencing the item.

thomas

Pecan deserves the find-most-stupid-random-crash-bug-2012 award.  8)

It's exactly as you say, wxArray::Remove(T&) retrieves the index of the element to be removed by comparing every item in the array against the to-be-removed item. It's a real pain to verify that, digging through 5 indirections of wx-macro-crap, but actually, if you think about it, that's kind of obvious -- there is hardly any other way it could be.

Thus, it's dereferencing unallocated memory, which sometimes works and sometimes crashes. The delete must be after Remove.

Commit your change please?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Pecan

#2
Could another team member commit this change.
Thomas ?
I only have permissions to modify my own plugins.

thomas

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Jenna

I changed this code again, because the crash still occured in some cases.
I hope it's finally done, by clearing both array after closing the projectfiles.
There is no need to remove the pointers one by one, because the arrays should be empty in all cases.
See also  http://forums.next.codeblocks.org/index.php/topic,15901.msg107151.html#msg107151 .