I have a std::vector<uint8_t> that contains strings at certain offsets. The dump is shortened here:
... @128 00 00 00 00 00 00 00 00 73 6F 6D 65 74 68 69 33 ........somethin @144 38 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ng.............. @160 00 00 00 00 00 00 00 00 31 2E 32 2E 33 00 00 00 ........1.2.3... @176 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ ...
I am trying to extract data with offset 136 and put it in std::string :
std::string x; x.assign(vec.begin()+136, vec.begin()+168);
This, however, leads to my segfault application. Now I am pretty new to Linux software development, but I know how to run my application in GDB and get the backtrace, and tracked the problem here:
(gdb) backtrace
Printing vec.size() returns 200 and even cyclically moves around the vector, and printing data does not cause me any problems (itโs definitely a failure over the fragment!).
I am compiling in Debian with g ++ 4.3.4. Any pointers to what this problem might be?
c ++ gcc stdstring segmentation-fault gdb
Daniel Sloof
source share