How to fix memory access error

I am working on a migration project, here we are migrating a large set of C ++ libraries from Mainframe to Solaris. We have successfully migrated, but during application launch some locations are reset with a SEGV signal (no display on the error address).

Since the application also supports windows, we tested with cleanup on windows. There are no memory leaks in the application and it works fine on windows.

Can anyone suggest what other reasons might be that could create this type of error. Any tools to track down this type of error?

0


source to share


4 answers


This is not necessarily a memory leak. Maybe a chunk of memory is referenced after it is free.



A friend of mine once came to me with a piece of code that works fine on Windows, but gives segv on Linux. It turned out that sometimes the memory stays valid after you freed it on Windows (maybe for a short period of time), but immediately called segv on Linux.

+1


source


The following line looks wrong to me

m_BindMap[sLabel] = b;   // crashes at this line at when map size

      



I am assuming you are trying to add a number to the end of the string. Try this instead

stringstream ss;
ss << ":BIND" << ns;
string sLabel = ss.str();

      

+1


source


Are you using g ++? If so, recompile the "-g" flag. Run the program in gdb. When it resets the type "bt" (for backtrace) and that should tell you where your problem is.

0


source


I am using the CC compiler on Solaris and the dbx debugger. I know the call stack where it falls. But this is a crash.

map<string,CDBBindParam,less<string> >m_BindMap;



CNumString ns(CNumStringTraits(0,2,'0'));
ns = m_BindMap.size();
string sLabel = ":BIND"+ns;
CDBBindParam b(sLabel,val);
**m_BindMap[sLabel] = b;**   // crashes at this line at when map size is more than 2
return sLabel;

      

0


source







All Articles