views:

419

answers:

4

Hi,

I am working on a migration project, here we are migrating large set of C++ libraries from Mainframe to Solaris. We have complted migration sucessfully, but while running the application, some places it crashes with 'signal SEGV (no mapping at the fault address)'.

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

Can any one suggests, what could be the other reasons which may create this type of errors. Any tools for tracing this type of errors?

A: 

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

eduffy
+1  A: 

It's not necessarily a memory leak. It could be that a piece of memory is referenced after it is free'ed.

My friend once came to me with a piece of code that runs fine on Windows but gives segv on Linux. It turned out that sometimes the memory is still valid after you free'ed it on Windows (probably for a short period of time) but immediately triggered segv on Linux.

PolyThinker
A: 

I am using CC compiler on solaris and dbx debugger. I know the call stack where it is crashing. But it is abromal 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;
+1  A: 

The line below looks wrong to me

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

I assume 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();
hamishmcn
":BIND"+ns means "ns" bytes past the start of ":BIND". When ns > 6, that puts you into lala land. Not sure about ns > 2, though.
Arkadiy