c++ - Trouble reading a Qt application stacktrace with gdb/qtdebugger -
i have program getting crash.
generally reading stacktrace not issue, in case cannot understand problem is. amunable know part of code causing crash.
i attaching gdb debugger stacktrace:
(gdb) r starting program: /home/r/l33t/kepler/build-supergui-5_2_1-debug/supergui [thread debugging using libthread_db enabled] using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". [new thread 0xb4762b40 (lwp 6612)] [new thread 0xb327cb40 (lwp 6613)] [new thread 0xb28ffb40 (lwp 6615)] [new thread 0xb1ea3b40 (lwp 6616)] [new thread 0xb16a2b40 (lwp 6617)] [new thread 0xb0ea1b40 (lwp 6618)] [thread 0xb16a2b40 (lwp 6617) exited] connecting... connected... [thread 0xb0ea1b40 (lwp 6618) exited] symbol --banknifty program received signal sigsegv, segmentation fault. __memcpy_ssse3 () @ ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s:2590 2590 ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s: no such file or directory. (gdb) bt #0 __memcpy_ssse3 () @ ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s:2590 #1 0x081ca9b0 in ?? () #2 0x3143041a in ?? () #3 0x03223930 in ?? () #4 0x2a363530 in ?? () #5 0x4e414209 in ?? () #6 0x46494e4b in ?? () #7 0xb2305954 in ?? () backtrace stopped: previous frame inner frame (corrupt stack?) can please me understand how read , how point in code causing crash information ?
the qt debugger more unhelpful :

the dissambler view of qt equally unhelpful (for me understand)
0xb711fe8d <+0x1cfd> sub $0x80,%ecx 2588 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s 0xb711fe93 <+0x1d03> movntdq %xmm0,(%edx) 2589 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s 0xb711fe97 <+0x1d07> movntdq %xmm1,0x10(%edx) 2590 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s 0xb711fe9c <+0x1d0c> movntdq %xmm2,0x20(%edx) 2591 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.s it said program crashed @ line 2589 in dissambler output ..
what wrong ?
here part of code think might causing crash (this working on right now)
void tradeview::readyread() { std::cout << "line 70" << "\n"; char delimiter_buffer[sizeof(google::protobuf::uint32)]; // read max size protobuf might write. memset(delimiter_buffer, '\0', sizeof(google::protobuf::uint32)); char* proto_data_buffer; // buffer should have been of type google::protobuf::uint8 //memset(proto_data_buffer, '\0', sizeof(google::protobuf::uint32)); google::protobuf::uint32 payload_size = 0; int space_takenby_delimiter = 0; size_t startof_extra_read, extra_read; std::cout << "line 79" << "\n"; if ( socket->read(delimiter_buffer, sizeof(google::protobuf::uint32)) != -1) { google::protobuf::io::arrayinputstream ais(delimiter_buffer,sizeof(google::protobuf::uint32)); google::protobuf::io::codedinputstream coded_input(&ais); coded_input.readvarint32(&payload_size); proto_data_buffer = new char[payload_size]; // buffer should have been of type google::protobuf::uint8 space_takenby_delimiter = coded_input.currentposition(); if (space_takenby_delimiter < 1) { std::cout << "could not read delimiter"; return; } if ( space_takenby_delimiter < sizeof(google::protobuf::uint32) ) { startof_extra_read = ( sizeof(google::protobuf::uint32) - (sizeof(google::protobuf::uint32) - space_takenby_delimiter) ); extra_read = (sizeof(google::protobuf::uint32) - space_takenby_delimiter); std::cout << "line 99" << "\n"; memcpy(proto_data_buffer, delimiter_buffer + startof_extra_read , extra_read); std::cout << "line 101" << "\n"; } } size_t bytes_stilltoberead = payload_size - extra_read; char payload_buffer[bytes_stilltoberead]; if ( socket->read(payload_buffer, bytes_stilltoberead) != -1) { std::cout << "line 110" << "\n"; memcpy(proto_data_buffer + extra_read, payload_buffer, bytes_stilltoberead); std::cout << "line 112" << "\n"; google::protobuf::io::arrayinputstream array_input(proto_data_buffer, payload_size); google::protobuf::io::codedinputstream coded_input(&array_input); data_model::terminal_data* tdata = new data_model::terminal_data(); if (!tdata->parsefromcodedstream(&coded_input)) std::cout << "could not fetch parse " << std::endl; else std::cout <<" symbol --" << tdata->symbol_name() << std::endl; } delete proto_data_buffer; } the above function slot in qt. invoked each time there data in socket. executes once (correctly) , there crash. have debug statement (as can see) @ first line of function. since not getting printed, guessing fucntion not @ fault ? because of function got screwed somewhere manifested crash ? getting pro me. can please me !
proto_data_buffer , extra_read not inited. if following condition not satisfied:
if ( socket->read(delimiter_buffer, sizeof(google::protobuf::uint32)) != -1) then proto_data_buffer point address. extra_read.
these lead wrong address operation in line:
memcpy(proto_data_buffer + extra_read, payload_buffer, bytes_stilltoberead);
Comments
Post a Comment