glibc detected : double free or corruption (!prev): ошибка GCC
Primary tabs
ПРИЧИНА ВОЗНИКНОВЕНИЯ ОШИБКИ МОЖЕТ БЫТЬ В ПОВТОРНОМ ЗАКРЫТИИ УЖЕ ЗАКРЫТОГО ФАЙЛА
то есть использовании кода типа=
fclose(something22); // закрыли файл ............. .. . .. . . . // вызвали разные функции , создали потоки .. .. . fclose(something22); /* снова попытались закрыть в одном из потоков и получили ошибку - glibc detected : double free or corruption */
в моём случае ошибка порождается где-то здесь =
#else /*далее часть кода , для линукс */
pthread_create( // создаём отдельный поток, который проведёт сравнение в линуксе
&thread1, // передаём указатель на глобальный идентфикатор нити thread1
NULL, // будем использовать атрибуты по-умолчанию
&t1_stand_func, // указатель на указатель на эту функцию c исполняемым кодом нити
&t1winp); // указатель на структуру из файловых дескрипторов
pthread_join(thread1,NULL);// ждём завершения процесса сравнения.
printf("\n [ comporasion in Linux for task1 was completed. ] \n");в смысле -строчка
printf("\n [ comporasion in Linux for task1 was completed. ] \n");уже не срабатывает.
и лезет ошибка - полный текст её здесь
Итак, glibc - это значит библиотека си, которая много чего обеспечивает.
Причина возникновения ошибки, в моём случае в том, что функция t1_stand_func (самописная)) - и несколько иерархически вызываемых ею функций несколько раз закрывали один раз открытый файл - этого не видно из приведённого мною примера - поэтому ошибку не легко определить сразу.
далее я выложу свою консоль - для того , чтобы больше людей могли выйти на мою заметку - и , как я надеюсь - исправить ошибку.
_____________________________________________
Источники(читать подробнее)=
http://www.linux.org.ru/forum/developmen...
Ключевые слова и фразы(для поиска)=
glibc detected : double free or corruption (!prev) pthread_join
00295000-00296000 rw-p 0001a000 08:05 97807 /lib/libgcc_s.so.1
0030a000-0030b000 r-xp 00000000 00:00 0 [vdso]
009cf000-009e4000 r-xp 00000000 08:05 97881 /lib/libpthread-2.12.1.so
009e4000-009e5000 ---p 00015000 08:05 97881 /lib/libpthread-2.12.1.so
009e5000-009e6000 r--p 00015000 08:05 97881 /lib/libpthread-2.12.1.so
009e6000-009e7000 rw-p 00016000 08:05 97881 /lib/libpthread-2.12.1.so
009e7000-009e9000 rw-p 00000000 00:00 0
00d27000-00d43000 r-xp 00000000 08:05 97749 /lib/ld-2.12.1.so
00d43000-00d44000 r--p 0001b000 08:05 97749 /lib/ld-2.12.1.so
00d44000-00d45000 rw-p 0001c000 08:05 97749 /lib/ld-2.12.1.so
08048000-0804b000 r-xp 00000000 08:05 201310 /home/vedro/t1/prog21
0804b000-0804c000 r--p 00002000 08:05 201310 /home/vedro/t1/prog21
0804c000-0804d000 rw-p 00003000 08:05 201310 /home/vedro/t1/prog21
09959000-0997a000 rw-p 00000000 00:00 0 [heap]
b6e00000-b6e21000 rw-p 00000000 00:00 0
b6e21000-b6f00000 ---p 00000000 00:00 0
b6f2d000-b6f2e000 ---p 00000000 00:00 0
b6f2e000-b7730000 rw-p 00000000 00:00 0
b773b000-b773f000 rw-p 00000000 00:00 0
bfed0000-bfef1000 rw-p 00000000 00:00 0 [stack]
Aborted
vedro@myone:~/t1$ gcc -pthread -c task1code.c comlib.c linfunc.c task1.c winfunc.c
vedro@myone:~/t1$ gcc -pthread task1code.o comlib.o linfunc.o task1.o winfunc.o -o prog21
vedro@myone:~/t1$ ./prog21
Glory to the great hacker, Linus Torvalds! we're not in Windows!
----------------
[If nothing take place - press enter to continue the program execution.]
Please specify the number of the task.
* You can choose on number from set = {1,2}
* Specify "0" to exit
* Choose "t" to test
1
[If nothing take place - press enter to continue the program execution.]
This is task1 menu=
* Specify "1" to use standard files for compare operations
* Choose "2" to specify your own files for comparing
* Specify "9" to come back in main menu
* Specify "0" to exit
1
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...text file conversion is started...]
[...number of lines had been found out = 12 ]
[...the quantity of symbols in file in each line had been found out...]
[...text file conversion is started...]
[...number of lines had been found out = 8 ]
[...the quantity of symbols in file in each line had been found out...]
[...two-demision array showing is started...]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...two-demision array showing is started...]
1345642575adfhgs sth sth
arthsfgnhjk
styj dukeyuks
arthty jkyukkkyukdu
sthtykj8lkldyu
00000000000000000000
[...comparasion of two two-demision arrays showing is started...]
===========
(0) (-) | [12fdg dfb] | [1345642575adfhgs sth sth]
---------------------
(1) (+) | [arthsfgnhjk ] | [arthsfgnhjk ]
---------------------
(2) (-) | [bfg] | [styj dukeyuks]
---------------------
(3) (-) | [] | [arthty jkyukkkyukdu]
---------------------
(4) (-) | [] | [sthtykj8lkldyu]
---------------------
(5) (-) | [123456789+0] | []
---------------------
(6) (-) | [9] | [00000000000000000000]
---------------------
(7) (-) | [1345346] | [__________]
---------------------
(8) (-) | [] | [__________]
---------------------
(9) (-) | [] | [__________]
---------------------
(10) (-) | [] | [__________]
---------------------
(11) (-) | [__________] | [__________]
---------------------
-----------
[ tdarrs_cmp() was completed in Linux ]
[ filesclosing is started in task1comp() in Linux ]
[ task1comp() was completed in Linux ]
[ t1_stand_func() was completed in Linux ]
[ comporasion in Linux for task1 was completed. ]
[If nothing take place - press enter to continue the program execution.]
Please specify the number of the task.
* You can choose on number from set = {1,2}
* Specify "0" to exit
* Choose "t" to test
t
[...open file for me now...]
[file is open]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...text file conversion is started...]
[...number of lines had been found out = 12 ]
[...the quantity of symbols in file in each line had been found out...]
[...text file conversion is started...]
[...number of lines had been found out = 8 ]
[...the quantity of symbols in file in each line had been found out...]
[...two-demision array showing is started...]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...two-demision array showing is started...]
1345642575adfhgs sth sth
arthsfgnhjk
styj dukeyuks
arthty jkyukkkyukdu
sthtykj8lkldyu
00000000000000000000
[...comparasion of two two-demision arrays showing is started...]
===========
(0) (-) | [12fdg dfb] | [1345642575adfhgs sth sth]
---------------------
(1) (+) | [arthsfgnhjk ] | [arthsfgnhjk ]
---------------------
(2) (-) | [bfg] | [styj dukeyuks]
---------------------
(3) (-) | [] | [arthty jkyukkkyukdu]
---------------------
(4) (-) | [] | [sthtykj8lkldyu]
---------------------
(5) (-) | [123456789+0] | []
---------------------
(6) (-) | [9] | [00000000000000000000]
---------------------
(7) (-) | [1345346] | [__________]
---------------------
(8) (-) | [] | [__________]
---------------------
(9) (-) | [] | [__________]
---------------------
(10) (-) | [] | [__________]
---------------------
(11) (-) | [__________] | [__________]
---------------------
-----------
[ tdarrs_cmp() was completed in Linux ]
*** glibc detected *** ./prog21: double free or corruption (!prev): 0x092c93f0 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6c501)[0xd5b501]
/lib/libc.so.6(+0x6dd70)[0xd5cd70]
/lib/libc.so.6(cfree+0x6d)[0xd5fe5d]
/lib/libc.so.6(fclose+0x14a)[0xd4b81a]
./prog21[0x8049adb]
./prog21[0x8048987]
./prog21[0x8048a4e]
./prog21[0x8048979]
./prog21[0x80488e4]
/lib/libc.so.6(__libc_start_main+0xe7)[0xd05ce7]
./prog21[0x8048841]
======= Memory map: ========
00339000-0033a000 r-xp 00000000 00:00 0 [vdso]
0047c000-00498000 r-xp 00000000 08:05 97749 /lib/ld-2.12.1.so
00498000-00499000 r--p 0001b000 08:05 97749 /lib/ld-2.12.1.so
00499000-0049a000 rw-p 0001c000 08:05 97749 /lib/ld-2.12.1.so
005f8000-0060d000 r-xp 00000000 08:05 97881 /lib/libpthread-2.12.1.so
0060d000-0060e000 ---p 00015000 08:05 97881 /lib/libpthread-2.12.1.so
0060e000-0060f000 r--p 00015000 08:05 97881 /lib/libpthread-2.12.1.so
0060f000-00610000 rw-p 00016000 08:05 97881 /lib/libpthread-2.12.1.so
00610000-00612000 rw-p 00000000 00:00 0
009fc000-00a16000 r-xp 00000000 08:05 97807 /lib/libgcc_s.so.1
00a16000-00a17000 r--p 00019000 08:05 97807 /lib/libgcc_s.so.1
00a17000-00a18000 rw-p 0001a000 08:05 97807 /lib/libgcc_s.so.1
00cef000-00e46000 r-xp 00000000 08:05 97773 /lib/libc-2.12.1.so
00e46000-00e47000 ---p 00157000 08:05 97773 /lib/libc-2.12.1.so
00e47000-00e49000 r--p 00157000 08:05 97773 /lib/libc-2.12.1.so
00e49000-00e4a000 rw-p 00159000 08:05 97773 /lib/libc-2.12.1.so
00e4a000-00e4d000 rw-p 00000000 00:00 0
08048000-0804b000 r-xp 00000000 08:05 201309 /home/vedro/t1/prog21
0804b000-0804c000 r--p 00002000 08:05 201309 /home/vedro/t1/prog21
0804c000-0804d000 rw-p 00003000 08:05 201309 /home/vedro/t1/prog21
092c8000-092e9000 rw-p 00000000 00:00 0 [heap]
b6e00000-b6e21000 rw-p 00000000 00:00 0
b6e21000-b6f00000 ---p 00000000 00:00 0
b6f7c000-b6f7d000 ---p 00000000 00:00 0
b6f7d000-b777f000 rw-p 00000000 00:00 0
b778a000-b778e000 rw-p 00000000 00:00 0
bfe1d000-bfe3e000 rw-p 00000000 00:00 0 [stack]
Aborted
vedro@myone:~/t1$ gcc -pthread -c task1code.c comlib.c linfunc.c task1.c winfunc.c
vedro@myone:~/t1$ gcc -pthread task1code.o comlib.o linfunc.o task1.o winfunc.o -o prog21
vedro@myone:~/t1$ ./prog21
Glory to the great hacker, Linus Torvalds! we're not in Windows!
----------------
[If nothing take place - press enter to continue the program execution.]
Please specify the number of the task.
* You can choose on number from set = {1,2}
* Specify "0" to exit
* Choose "t" to test
t
[...open file for me now...]
[file is open]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...text file conversion is started...]
[...number of lines had been found out = 12 ]
[...the quantity of symbols in file in each line had been found out...]
[...text file conversion is started...]
[...number of lines had been found out = 8 ]
[...the quantity of symbols in file in each line had been found out...]
[...two-demision array showing is started...]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...two-demision array showing is started...]
1345642575adfhgs sth sth
arthsfgnhjk
styj dukeyuks
arthty jkyukkkyukdu
sthtykj8lkldyu
00000000000000000000
[...comparasion of two two-demision arrays showing is started...]
===========
(0) (-) | [12fdg dfb] | [1345642575adfhgs sth sth]
---------------------
(1) (+) | [arthsfgnhjk ] | [arthsfgnhjk ]
---------------------
(2) (-) | [bfg] | [styj dukeyuks]
---------------------
(3) (-) | [] | [arthty jkyukkkyukdu]
---------------------
(4) (-) | [] | [sthtykj8lkldyu]
---------------------
(5) (-) | [123456789+0] | []
---------------------
(6) (-) | [9] | [00000000000000000000]
---------------------
(7) (-) | [1345346] | [__________]
---------------------
(8) (-) | [] | [__________]
---------------------
(9) (-) | [] | [__________]
---------------------
(10) (-) | [] | [__________]
---------------------
(11) (-) | [__________] | [__________]
---------------------
-----------
[ tdarrs_cmp() was completed in Linux ]
[If nothing take place - press enter to continue the program execution.]
Please specify the number of the task.
* You can choose on number from set = {1,2}
* Specify "0" to exit
* Choose "t" to test
1
[If nothing take place - press enter to continue the program execution.]
This is task1 menu=
* Specify "1" to use standard files for compare operations
* Choose "2" to specify your own files for comparing
* Specify "9" to come back in main menu
* Specify "0" to exit
1
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...open file for me now...]
[file is open]
[...text file conversion is started...]
[...number of lines had been found out = 12 ]
[...the quantity of symbols in file in each line had been found out...]
[...text file conversion is started...]
[...number of lines had been found out = 8 ]
[...the quantity of symbols in file in each line had been found out...]
[...two-demision array showing is started...]
12fdg dfb
arthsfgnhjk
bfg
123456789+0
9
1345346
[...two-demision array showing is started...]
1345642575adfhgs sth sth
arthsfgnhjk
styj dukeyuks
arthty jkyukkkyukdu
sthtykj8lkldyu
00000000000000000000
[...comparasion of two two-demision arrays showing is started...]
===========
(0) (-) | [12fdg dfb] | [1345642575adfhgs sth sth]
---------------------
(1) (+) | [arthsfgnhjk ] | [arthsfgnhjk ]
---------------------
(2) (-) | [bfg] | [styj dukeyuks]
---------------------
(3) (-) | [] | [arthty jkyukkkyukdu]
---------------------
(4) (-) | [] | [sthtykj8lkldyu]
---------------------
(5) (-) | [123456789+0] | []
---------------------
(6) (-) | [9] | [00000000000000000000]
---------------------
(7) (-) | [1345346] | [__________]
---------------------
(8) (-) | [] | [__________]
---------------------
(9) (-) | [] | [__________]
---------------------
(10) (-) | [] | [__________]
---------------------
(11) (-) | [__________] | [__________]
---------------------
-----------
[ tdarrs_cmp() was completed in Linux ]
[ filesclosing is started in task1comp() in Linux ]
[ task1comp() was completed in Linux ]
[ t1_stand_func() was completed in Linux ]
[ comporasion in Linux for task1 was completed. ]
[If nothing take place - press enter to continue the program execution.]
^A^C
vedro@myone:~/t1$
- vedro-compota's blog
- Log in to post comments
- 7115 reads