bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with 'fclose' function on GNU/Linux system


From: André E . Gabriel da Silva
Subject: Problem with 'fclose' function on GNU/Linux system
Date: Tue, 7 Nov 2000 14:13:46 -0200

Hello!

        I'm having a problem with my program and I need help!

        My program is an implementation of the "k-ways external sort"
algorithm as it is explained in the N. Wirth book "Algorithms + Data
structures", but in C language.
        I'm using a GNU/Linux system, kernel 2.2.5, glibc-2.1.1 and egcs
1.1.2 to compile and run the program. The hardware is an Intel Pentium II
350MHz, 64MB primary memory, 1.5GB h.d. total.

        The program accepts 2 parameters: the name of the binary file to
sort and the "nh" number. It will create N=2*nh temporary files to do the
sort. The algorithm is working well (I tried it in Windows systems too, an
it worked entirely well), it is sorting the file correctly, but, in some
cases, when it is closing the temporary files (with 'fclose'), it receives a
signal of "segmentation fault" and do a core dump.

        Well, gdb says the error occurred inside the function "malloc"
(chunk_free), file "malloc.c", line 3020. But the program didn't called
malloc! It called 'fclose'! As I said, the program uses 2*nh files, and it
closes the files from 1 to (2*nh)-1 without problems: the problem occurs
always on the last file!

        Another unusual thing is that the problem doesn't happens with any
"nh" number. The program works fine with nh=3, 6, 8, 12, 15 20, 21 and 27.
But it doesn't work when nh=2, 4, 5, 7, 9, 10, 11, 13, 14, 16, 17, 18, 19,
22, 23, 24, 25 and 26.

        Can you help me? Any kind of help will be welcome: something like an
address (http) where I can search for help, an e-mail of someone that can
help me, a newsgroup where I can ask for help, I don't know... any kind of
help.

        Just for illustrate, I attached the source file of my program and a
binary file used for testing the program.

        I will be very glad for any explanation of the problem and, if
possible, the solution! :-)

Thanks
André.
São Paulo - Brasil
address@hidden

Attachment: Balanc-n.c
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]