My code compiles fine with gcc. 4.1.1 gcc /home/path/indo18b.c -o /home/path/indo18b -lm -lz Yet, during run-time, the first data file in a sequence of X files will usually be opened and read without much problem. The next data file, when attempting to open, will yield the error: .... *** glibc detected *** ./indo18b: malloc(): memory corruption: 0x45a1f169 *** ======= Backtrace: ========= /lib/libc.so.6[0x459530f2] /lib/libc.so.6(malloc+0x73)[0x459547f4] /lib/libc.so.6[0x459437ed] /lib/libc.so.6(fopen+0x2c)[0x459438ae] ./indo18b[0x804d2fb] ./indo18b[0x80491e4] /lib/libc.so.6(__libc_start_main+0xdc)[0x459044e4] ./indo18b[0x80488a1] ======= Memory map: ======== 08048000-08056000 r-xp 00000000 fd:00 71893185 /home/path/indo18b 08056000-08057000 rw-p 0000d000 fd:00 71893185 /home/path/indo18b 08057000-080d0000 rw-p 08057000 00:00 0 [heap] 458d2000-458eb000 r-xp 00000000 fd:00 48693429 /lib/ld-2.4.so 458eb000-458ec000 r--p 00018000 fd:00 48693429 /lib/ld-2.4.so 458ec000-458ed000 rw-p 00019000 fd:00 48693429 /lib/ld-2.4.so 458ef000-45a1c000 r-xp 00000000 fd:00 48693446 /lib/libc-2.4.so 45a1c000-45a1e000 r--p 0012d000 fd:00 48693446 /lib/libc-2.4.so 45a1e000-45a1f000 rw-p 0012f000 fd:00 48693446 /lib/libc-2.4.so 45a1f000-45a22000 rw-p 45a1f000 00:00 0 45a24000-45a47000 r-xp 00000000 fd:00 48693447 /lib/libm-2.4.so 45a47000-45a48000 r--p 00022000 fd:00 48693447 /lib/libm-2.4.so 45a48000-45a49000 rw-p 00023000 fd:00 48693447 /lib/libm-2.4.so 45b5d000-45b6f000 r-xp 00000000 fd:00 200994 /usr/lib/libz.so.1.2.3 45b6f000-45b70000 rw-p 00011000 fd:00 200994 /usr/lib/libz.so.1.2.3 45c7e000-45c89000 r-xp 00000000 fd:00 48694800 /lib/libgcc_s-4.1.1-20060525.so.1 45c89000-45c8a000 rw-p 0000a000 fd:00 48694800 /lib/libgcc_s-4.1.1-20060525.so.1 b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f59000-b7f5a000 rw-p b7f59000 00:00 0 b7f76000-b7f78000 rw-p b7f76000 00:00 0 bfef2000-bff07000 rw-p bfef2000 00:00 0 [stack] ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] Aborted This DOES NOT happen consistently. All the files have the exact same format and length (in terms of wc -l {f_name} ) --they just contain ASCII data. I have traced the offending line to the fopen statement. Read through all documentation I could find that indicates I am not doing anything really strange or wrong. Am I missing something? Please suggest solution....I am using Fedora Core 5. Embarrassingly, I admit I am unsure how to adjust the heap or stack. CODE PART: void get_data(void) { // [variable initialisation abridged] FILE *fp_get2; // following line is where problem typically occures fp_get2 = fopen(f_look, "r"); if (fp_get2 == NULL) { printf("Error: Can't find the data file. Does it exist?\n"); got_data_file=0; return; } else { // rest of code in this subroutine to read and parse data abridged } fclose(fp_get2); return; } Whether fp_get2 is local or global makes no difference. Sometimes, entire sequences of data files are read without much ado. Sometimes, only the first data file in a sequence can be read.