У меня где-то утечка памяти, и, к сожалению, повторяющаяся тема, которая появляется о переполнении стека, не помогла;Я не совсем понимаю, как это происходит, так как я идентифицировал сомнительную строку из прогона gdb,
void read_data(std::string filename, number_type & parameter, number_type & n_part, number_type & mult){
std::ifstream infile(filename);
std::string line; // ERROR LINE
size_type counter_numbers = 0;
size_type counter_lines = 0;
while (infile)
{
std::getline(infile, line); // Read in current line
.
.
это то, где это показано в gdb: free (): неверный следующий размер (нормальный);при определении строки. Почему это случилось? Есть идеи?
спасибо, Дамир
Работает как
g++ -std=c++11 -I/users/damir/gsl/include/ -L/users/damir/gsl/lib/ -lgsl -lgslcblas -g -o MultB analysis_mult_b.cpp
PS (вывод valgrind)
valgrind ./MultB arg1 arg2 arg3 arg4
==39918== Command: ./MultB arg1 arg2 arg3 arg4
==39918==
==39918== Invalid write of size 8
==39918== at 0x405B55: ??? (in /users/damir/Analysis/MultB)
==39918== by 0x404531: ??? (in /users/damir/Analysis/MultB)
==39918== by 0x5582B44: (below main) (libc-start.c:287)
==39918== Address 0x591e530 is 0 bytes after a block of size 400 alloc'd
==39918== at 0x4C28C20: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==39918== by 0x512B654: ??? (in /cvmfs/it/compiler/gcc/9.1.0/lib64/libstdc++.so.6.0.26)
==39918== by 0x404531: ??? (in /users/damir/Analysis/MultB)
==39918== by 0x5582B44: (below main) (libc-start.c:287)
==39918==
--39918-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting
--39918-- si_code=80; Faulting address: 0x0; sp: 0x802b99de0
valgrind: the 'impossible' happened:
Killed by fatal signal
host stacktrace:
==39918== at 0x380B1870: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==39918== by 0x38072784: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==39918== by 0x38072956: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==39918== by 0x380F6D27: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==39918== by 0x38105B60: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
sched status:
running_tid=1
Thread 1: status = VgTs_Runnable
==39918== at 0x4C28C20: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==39918== by 0x512B654: ??? (in /cvmfs/it/compiler/gcc/9.1.0/lib64/libstdc++.so.6.0.26)
==39918== by 0x40455D: ??? (in /users/damir/Analysis/MultB)
==39918== by 0x5582B44: (below main) (libc-start.c:287)
Вывод из readlef -WS ./MultB
:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000000004002a8 0002a8 00001c 00 A 0 0 1
[ 2] .note.ABI-tag NOTE 00000000004002c4 0002c4 000020 00 A 0 0 4
[ 3] .hash HASH 00000000004002e8 0002e8 000334 04 A 5 0 8
[ 4] .gnu.hash GNU_HASH 0000000000400620 000620 00005c 00 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000400680 000680 0009f0 18 A 6 1 8
[ 6] .dynstr STRTAB 0000000000401070 001070 000fe1 00 A 0 0 1
[ 7] .gnu.version VERSYM 0000000000402052 002052 0000d4 02 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000402128 002128 0000c0 00 A 6 4 8
[ 9] .rela.dyn RELA 00000000004021e8 0021e8 000048 18 A 5 0 8
[10] .rela.plt RELA 0000000000402230 002230 000918 18 AI 5 24 8
[11] .init PROGBITS 0000000000403000 003000 00001a 00 AX 0 0 4
[12] .plt PROGBITS 0000000000403020 003020 000620 10 AX 0 0 16
[13] .plt.got PROGBITS 0000000000403640 003640 000008 08 AX 0 0 8
[14] .text PROGBITS 0000000000403650 003650 00a342 00 AX 0 0 16
[15] .fini PROGBITS 000000000040d994 00d994 000009 00 AX 0 0 4
[16] .rodata PROGBITS 000000000040e000 00e000 000208 00 A 0 0 16
[17] .eh_frame_hdr PROGBITS 000000000040e208 00e208 0010cc 00 A 0 0 4
[18] .eh_frame PROGBITS 000000000040f2d8 00f2d8 004568 00 A 0 0 8
[19] .gcc_except_table PROGBITS 0000000000413840 013840 00049c 00 A 0 0 4
[20] .init_array INIT_ARRAY 0000000000414db0 013db0 000010 08 WA 0 0 8
[21] .fini_array FINI_ARRAY 0000000000414dc0 013dc0 000008 08 WA 0 0 8
[22] .dynamic DYNAMIC 0000000000414dc8 013dc8 000230 10 WA 6 0 8
[23] .got PROGBITS 0000000000414ff8 013ff8 000008 08 WA 0 0 8
[24] .got.plt PROGBITS 0000000000415000 014000 000320 08 WA 0 0 8
[25] .data PROGBITS 0000000000415320 014320 000010 00 WA 0 0 8
[26] .bss NOBITS 0000000000415340 014330 000138 00 WA 0 0 32
[27] .comment PROGBITS 0000000000000000 014330 00002d 01 MS 0 0 1
[28] .debug_aranges PROGBITS 0000000000000000 01435d 002060 00 0 0 1
[29] .debug_info PROGBITS 0000000000000000 0163bd 024611 00 0 0 1
[30] .debug_abbrev PROGBITS 0000000000000000 03a9ce 000e97 00 0 0 1
[31] .debug_line PROGBITS 0000000000000000 03b865 005f1d 00 0 0 1
[32] .debug_str PROGBITS 0000000000000000 041782 025677 01 MS 0 0 1
[33] .debug_ranges PROGBITS 0000000000000000 066df9 002260 00 0 0 1
[34] .symtab SYMTAB 0000000000000000 069060 004e60 18 35 57 8
[35] .strtab STRTAB 0000000000000000 06dec0 00a877 00 0 0 1
[36] .shstrtab STRTAB 0000000000000000 078737 000154 00 0 0 1