Hi,
I got a crash stacktrace which is...
------------------------------------------------------------------
............
...............
leafNodeArray::elementAt(int) const
leafNodeArray::sort() const
std::_Rb_tree_increment(std::_Rb_tree_node_base const*)
------------------------------------------------------------------
I have tried to put the actual useful code snippet below (by slightly modifiing the names...). In run time, the map table has lot of entries. I do not have the testcase to reproduce the issue for the crash. I just have to statically analyze the code and see if the root cause can be found.
(i) from std::_Rb_tre_increment , does it mean that ++p is the culprit..
(ii) The crash happens on 64 bit machines. Can it be the case that the index which is being typecasted from int to unsigned int is creating some problem.
Any help is welcome.?
--------------------------sample similar code...-------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <map>
class leafNode {
};
main() {
//const leafNodeArray * leaves = root->getLeafNodes();
// In actual scenario the leaves are not empty and do have... proper length.
const leafNodeArray * leaves = new leafNodeArray();
if (leaves) {
int count = leaves->getLength();
for(int i=0;i < count; i++) {
const leafNode * tempLeaf = leaves->elementAt(i);
//.... do some read only operation with leafNode
}
}
}
-----------------------------------------------
Sorry,
I missed one line, the sort function sets the _isSorted = TRUE after the for loop. Hence next sort() function will not go through the loop.
Next you are hinting at the NULL check for _sortedArray. That means you are saying that the new() function has failed and may be we can have a try-catch which catches a bad_alloc. Are you pointing towards a memory allocation failure??