Patch #1881 2007-02-10 16:49
pecan
Fix for Debugger termination crashes- Download
- 1881-Fix_for_Debugg.patch (2.0 KB)
- Category
- Status
- Rejected
- Close date
- 2007-06-27 10:53
- Assigned to
The follow fixes Bug reports 9655 & 10077 crashes in Debugger
The problem occurs when OnGDBTerminate frees m_pDriver while OnGDBOutput still has messages to process.
Index: debuggergdb.cpp
===================================================================
--- debuggergdb.cpp (revision 3590)
+++ debuggergdb.cpp (working copy)
@@ -227,7 +227,8 @@
m_pBreakpointsWindow(0),
m_pExamineMemoryDlg(0),
m_pThreadsDlg(0),
- m_pProject(0)
+ m_pProject(0),
+ m_GDBInputKnt(0)
{
if(!Manager::LoadResource(_T("debugger.zip")))
{
@@ -1909,12 +1910,19 @@
void DebuggerGDB::OnGDBOutput(wxCommandEvent& event)
{
+ ++m_GDBInputKnt;
wxString msg = event.GetString();
if (!msg.IsEmpty())
{
// Manager::Get()->GetMessageManager()->Log(m_PageIndex, _T("O>>> %s"), msg.c_str());
ParseOutput(msg);
}
+ --m_GDBInputKnt;
+ if ( (not m_pProcess) && m_State.HasDriver() && (m_GDBInputKnt==0) )
+ { m_State.StopDriver();
+ DebugLog(wxT("ParseOutput() closed m_State.Driver"));
+ }
+
}
void DebuggerGDB::OnGDBError(wxCommandEvent& event)
@@ -1937,7 +1945,14 @@
// m_pProcess = 0L;
ClearActiveMarkFromAllEditors();
- m_State.StopDriver();
+ // closing the GDB driver here causes crashes because input msgs
+ // are still queued up in OnGDBOutput/ParseOutput //(pecan 2007/2/09)
+ //-m_State.StopDriver();
+ if ( (not m_pProcess) && m_State.HasDriver() && (m_GDBInputKnt==0) )
+ { m_State.StopDriver();
+ DebugLog(wxT("OnGDBTerminate() closed m_State.Driver"));
+ }
+
Manager::Get()->GetMessageManager()->Log(m_PageIndex, _("Debugger finished with status %d"), m_LastExitCode);
if (m_NoDebugInfo)
Index: debuggergdb.h
===================================================================
--- debuggergdb.h (revision 3590)
+++ debuggergdb.h (working copy)
@@ -204,6 +204,7 @@
SearchDirsMap m_SearchDirs;
int m_HookId; // project loader hook ID
+ int m_GDBInputKnt;
DECLARE_EVENT_TABLE()
};
History
pecan 2007-02-10 17:06
The following program can reproduce this bug in two ways.
The first just waits for input, hit the stop button, then crash.
The second put the pgm in a sleep loop. Hit the stop button, crash.
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int upstring(char *value);
int main()
{
//asm("int3");
char value[81]={'\0'};
int upper_count;
// perform i/o operation
do
{ cout << "Please type in a String (max. 80 characters): ";
cin.getline(value, 80);
upper_count = upstring(value);
cout << upper_count << " characters are converted" << endl;
cout << "The new string is now: " << value << endl;
if ( (strlen(value) >3) && (0==strncmp(value,"LOOP",4) ))
break;
}while(upper_count);
// perform infinite loop if user entered text "loop"
if ( (strlen(value) >3) && (0==strncmp(value,"LOOP",4)) )
{
int i = 0;
while(true){
cout<<".";cout.flush();
++i;
sleep(1);
}
}
return EXIT_SUCCESS;
}
int upstring(char *value)
{
int i=0;
while(*value)
{
if(islower(*value))
{
*value=toupper(*value);
i++;
}
value++;
}
return(i);
}
pecan 2007-03-02 18:18
Fixed by SVN 3659
rickg22 2007-06-26 23:23
Pecan, what's the status of this patch? Was the bug fixed in trunk or not? I need to know so I can close Bug #9655.
pecan 2007-06-27 10:53
This bug was fixed in another way by mandrav.