User forums > Using Code::Blocks

C::B crash (Settings-->Editor)

<< < (8/16) > >>

Pecan:

--- Quote ---However, your crash is very strange because I can't understand where there can be an error in "languages[0].name = _T("C/C++");", just before your crash. There is no problem of memory allocation because "languages" is an array of fixed size.

--- End quote ---

The allocation crash is not in the allocation of the lanugages
array, it's in the allocation of memory for the creation of the
wxString. wxGTK is allocating 2 byte at a time and copying
"C/C++" into a wxString at AllocBeforWrite().

pecan

Michael:

--- Quote from: Pecan on April 17, 2006, 10:03:14 pm ---
--- Code: ---"languages[0].name = _T("C/C++");"

--- End code ---

To see if it's a wxGTK error in wxString operator=() try
the following on the first assignment statement and
see if the crash moves to the second assignment.


--- Code: ---"languages[0].name = wxString(_T("C/C++"));"

--- End code ---

This forces the creation of the string form operator=
to wxString::Clear() and then to wxString::Append().

This is looking more and more like a wxGTK error, but
I couldn't find anything about an assignment bug on
google or wxWidgets.

--- End quote ---

It still crash, but with a difference:


--- Quote ---#0  0xb7a4a349 in wxStringBase::AllocBeforeWrite ()
   from /usr/lib/libwx_baseu-2.6.so.0
#1  0xb7a4acb0 in wxStringBase::AssignCopy ()
   from /usr/lib/libwx_baseu-2.6.so.0
#2  0xb7a4ad34 in wxStringBase::operator= () from /usr/lib/libwx_baseu-2.6.so.0
#3  0x0806da16 in wxString::operator= (this=0x98db36c, psz=0xb5cd1210)
    at string.h:854
#4  0xb5cba35e in LoadDefaultSettings (languages=0x98db36c)
    at codestatconfig.cpp:224
[...]

--- End quote ---

The cause for the SIGSEGV seems now to be the wxStringBase::operator= () from /usr/lib/libwx_baseu-2.6.so.0.

Best wishes,
Michael

Pecan:
Here's the code executed during the assignment.
Notice that the assignment can fail if memory allocation fails.
No message will occur because wxFail_Msg is issued only in
__wxDEBUG__ mode.

--- Code: ---// assigns C string
wxStringBase& wxStringBase::operator=(const wxChar *psz)
{
  if ( !AssignCopy(wxStrlen(psz), psz) ) {
    wxFAIL_MSG( _T("out of memory in wxStringBase::operator=(const wxChar *)") );
  }
  return *this;
}

// helper function: does real copy
bool wxStringBase::AssignCopy(size_t nSrcLen, const wxChar *pszSrcData)
{
  if ( nSrcLen == 0 ) {
    Reinit();
  }
  else {
    if ( !AllocBeforeWrite(nSrcLen) ) {
      // allocation failure handled by caller
      return false;
    }
    memcpy(m_pchData, pszSrcData, nSrcLen*sizeof(wxChar));
    GetStringData()->nDataLength = nSrcLen;
    m_pchData[nSrcLen] = wxT('\0');
  }
  return true;
}



--- End code ---

Is it possible that your're giving out of memory? How much memory
do you have on that system?

pecan

Michael:

--- Quote from: Pecan on April 18, 2006, 12:11:38 am ---Is it possible that your're giving out of memory? How much memory
do you have on that system?

--- End quote ---

After the System Monitor I have 504.4MB User Memory and 528.0MB Used swap.

I would exclude a lack of memory.

Best wishes,
Michael

Pecan:
Michael,
Would you change statement at line 224 to the following to see
if wxgtk is miscalculating the string length.


--- Code: ---    languages[0].name = wxString(_T("C/C++"),14);

--- End code ---

thanks
pecan

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version