Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It all started when I wrote a program using malloc, everything was ok until I executed it, then it said "glibc detected free() XX". I googled it, and didn't find much, other than someone saying to upgrade to the latest glibc version and coreutils, which I did.
Quote:
I would download the latest glibc package
(download not upgrade with swaret, just download)
Then I'd do a telinit 1 as root and upgradepkg glibc-xxx.tgz
After that, telinit 3 and upgrade coreutils package if newer
version is available
Although, when I typed "telinit 1" as told to, it just crashed my box, so I did it without doing it...
Now when I try and compile a program I get this:
Code:
bt programming # gcc sounds.c -o sounds
/usr/lib/gcc/i486-slackware-linux/3.4.6/../../../../i486-slackware-linux/bin/ld:/usr/lib/gcc/i486-slackware-linux/3.4.6/ ../../../libc.so: file format not recognized; treating as linker script
/usr/lib/gcc/i486-slackware-linux/3.4.6/../../../../i486-slackware-linux/bin/ld:/usr/lib/gcc/i486-slackware-linux/3.4.6/ ../../../libc.so:5: parse error
collect2: ld returned 1 exit status
Code:
bt ~ $ /lib/libc.so.6
GNU C Library stable release version 2.7, by Roland McGrath et al.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.1.2.
Compiled on a Linux >>2.6.23.15-smp<< system on 2008-02-09.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
bt ~ $ uname -a
Linux bt 2.6.20-NOSMP #3 Sat Feb 24 15:52:59 GMT 2007 i686 Intel(R) Pentium(R) M processor 1.80GHz GenuineIntel GNU/Linux
All I want to do is compile and run something, but it seems like a complete headache.
Make sure you are in the directory the sourse file is, or give the path.
That's not the issue, I can compile it now, as I reinstalled the older version of glibc. It's just now, after I malloc'd some memory, when I try to free() it, it doesn't like it - just like before.
Code:
if((mem_ptr2 = malloc(sizeof(char)*lsize2)) == NULL) {
puts("Error assigning memory\n");
exit(0);
}
for(y = 0; y != lsize ; y++) {
g = fgetc(fptr2);
mem_ptr2[y] = g;
}
for(x=0; x != lsize; x++) {
if(mem_ptr[x] != mem_ptr2[x]) {
k = (mem_ptr[x] ^ mem_ptr[++x]);
--x;
printf("%c\n", k);
}
}
free(mem_ptr); <<<<<<<< Doesn't like these
free(mem_ptr2);
fclose(fptr);
fclose(fptr2);
exit(0);
}
I've gotten that error before. It generally means you have a bug in your code that has messed up the pointer so it's pointing to memory you did not malloc. This calls free to get confused as it can't find the bookkeeping information it stored when it malloc'ed the chunk. You can use a memory debugger like Valgrind to help you find the error, or simply examine your code. I didn't find anything too suspicious in the sample you posted, so it may occur somewhere else (like where you malloc mem_ptr). In no case should you attempt to upgrade glibc because of something like this -- you're fortunate you didn't destroy your system (I've done this with bad glibc updates before)!
I've gotten that error before. It generally means you have a bug in your code that has messed up the pointer so it's pointing to memory you did not malloc. This calls free to get confused as it can't find the bookkeeping information it stored when it malloc'ed the chunk. You can use a memory debugger like Valgrind to help you find the error, or simply examine your code. I didn't find anything too suspicious in the sample you posted, so it may occur somewhere else (like where you malloc mem_ptr). In no case should you attempt to upgrade glibc because of something like this -- you're fortunate you didn't destroy your system (I've done this with bad glibc updates before)!
Yeah, you're right dude. I'm so arrogant about my coding "Oh it couldn't be my code", I practically took my OS apart trying to fix it without taking other possibilities into account. I did something stupid earlier on in the code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.