stdmap - C++ std::map std::bitset segfault -


i have code:

static void xmlcall hackhandler(void *data, const xml_char *name, const xml_char **attr) { setpointers* sets = static_cast<setpointers*>(data); if (strcmp(name, "instruction") == 0 || strcmp(name, "load") == 0 ||     strcmp(name, "modify") == 0||strcmp(name, "store") == 0) {     long address(0);     long page(0);     int offset(0);     long size(0);     int i(0);     (i = 0; attr[i]; += 2) {         if (strcmp(attr[i], "address") == 0) {             address = strtol(attr[i+1], null, 16);             page = address >> 12;             offset = address & 0xfff;             continue;         }         if (strcmp(attr[i], "size") == 0) {             size = strtol(attr[i + 1], null, 16);         }     }     map<long, bitset<4096> >::iterator itlocal;      itlocal = sets->lcount->find(page);     if (itlocal == sets->lcount->end()) {         sets->lcount->insert(pair<long, bitset<4096> >             (page, bitset<4096>()));         itlocal = sets->lcount->find(page);     }     //now mark bitmap     (i = 0; < size; i++) {         (itlocal->second)[i + offset] = 1;     }      if (strcmp(name, "instruction") == 0) {         itlocal = sets->lcode->find(page);         if (itlocal == sets->lcode->end()) {             sets->lcode->insert(pair<long, bitset<4096> >                 (page, bitset<4096>()));             itlocal = sets->lcode->find(page);         }         (i = 0; < size; i++) {             (itlocal->second)[i + offset] = 1;         }     } else {         itlocal = sets->lmemory->find(page);         if (itlocal == sets->lmemory->end()) {             sets->lmemory->insert(pair<long, bitset<4096> >                 (page, bitset<4096>()));             itlocal = sets->lmemory->find(page);         }         (i = 0; < size; i++) {             (itlocal->second)[i + offset] = 1;         }     } } } 

this aims mark bitset, 4096 bits long, 1 when byte of page accessed.

this code works on test machine, when use 1gb of xml test. when run on full thing (220gb of xml) gives segmentation fault on:

 sets->lcode->insert(pair<long, bitset<4096> >             (page, bitset<4096>())); 

but on in run, it's difficult think product of size of data. in case have had no problem in analysing larger data set using similar code (check github repo @ https://github.com/mcmenaminadrian - project memsize, pagestat uses siumilar code). differentiating factor code seems use of bitset.

can spot error has eluded me far?

(the code multithreaded - bitset thread safe? library issue - test system mac osx, "production" system linux - ubuntu 12.04 lts?)

there no checks make sure i + offset less 4096. source of problem.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -