Core dump with deque program

Hey all, here is the small deque program...

When this program was run for upto 529 entires it works fine. When tried for 530 entries it dumps core.

By the way instead of push_front if we use push_back, it works fine. However, we are facing this problem with Sun ONE Studio 11 after our successful compiler upgrade.

If any one has any idea why the following program dumping core with 530 entires?

cut and paste and compile and run ./deque 530, you will receive a core dump in Solaris 10/Sun one Studio 11 (CC 5.8 compiler). Important: make sure you run Solaris 10/Sun One Studio 11 CC 5.8 compiler compiled code.

IT IS NOT DUMPING CORE IN OLDER VERSIONS....

==========deque.cc===================

#include <deque>

#include <iostream>

int main( int argc, char* argv[] )

{

std::deque< int > container;

std::cout << "maxSize:" << container.max_size() << "\n";

int last( 530 );

if ( argc > 1 )

{

last = atoi( argv[ argc - 1 ] );

}

std::cout << "Building to " << last << "\n";

for ( int i = 0; i < last; ++ i )

{

container.push_front( i );

}

int idx = 0;

for ( std::deque< int >::const_iterator

iter = container.begin();

iter != container.end();

++ iter, ++ idx )

{

std::cout << idx << ": " << (*iter) << "\n";

}

std::cout << "maxSize:" << container.max_size() << "\n";

return 0;

}

The pstack output from core file...

core 'core.deque' of 3869:./deque 530

00011a40 main(2, ffbfd7ec, ffbfd758, ffbfd768, ffbfd768, ffbfd630) + 2b8

00011358 _start(0, 0, 0, 0, 0, 0) + 108

[1806 byte] By [Sara_Kan] at [2007-11-26 10:47:22]
# 1
I can duplicate your problem with the original release of Sun Studio 11, but not with any patched version. Get the current patches from the Sun Studio patch page, and that should solve your problem: http://developers.sun.com/sunstudio/downloads/patches/index.jsp
clamage45 at 2007-7-7 2:59:38 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
It's possible that the bug you observe is known as CR 6363210: std::deque memory corruption. It has been fixed in both Sun Studio Express and Studio 11 patch (specifically, 121018-05). You may try to apply the patch and see if it helps.Best regards,Boris
Boris_Ivanovsky at 2007-7-7 2:59:38 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
I am having a similar problem, but am told that the patch to fix CR 6363210 is already installed. Was the original poster able to solve this problem by adding the latest patches? Or does this appear to be a different defect?Thanks...
mason_samuels at 2007-7-7 2:59:38 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

The patch that fixes CR 6363210 involves the header files for the deque implementation in Sun Studio 10 and 11. The runtime library /usr/lib/libCstd.so.1 also has that code in it. Whether you generate the affected functions inline in your code, or pick them up from the runtime library, depends on various compiler options.

If you have not installed the latest C++ runtime library patch and get these functions from the runtime library, you will not have the benefit of the bug fix.

You can get all current patches here:

http://developers.sun.com/sunstudio/downloads/patches/index.jsp

If after installing current patches you still have the problem, please post a stand-alone code example that shows the problem.

clamage45 at 2007-7-7 2:59:38 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
With both the compiler and the c++ runtime library patch installed, the problem is indeed fixed.Thanks for your assistance,Mason
mason_samuels at 2007-7-7 2:59:38 > top of Java-index,Development Tools,Solaris and Linux Development Tools...