LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 06-15-2006, 06:37 AM   #1
ColonelPanic
Member
 
Registered: Jun 2006
Distribution: Ubuntu 7.10, Mandriva 2008
Posts: 40

Rep: Reputation: 15
Recompile standard kernel - loads of errors


Hi there,

I'm still in the learning process with compiling and driver install so I thought it would be a good idea to practice with a recompile of the standard kernel without changing any settings. I followed all instructions for kernel recompile to the T but then at 'make modules' I see lots and lots of errors, often error 2, sometimes error 1.
BTW I started the process with --ignore-erros just to get through the run and see what it did.

How is it possible for a kernel to run properly with THAT many errors? I didn't modify anything, I just installed the source from the Mandriva DVD and did xconfig etc. without changing any parametre.



The reason why I ask is that I need to install a driver update for my TV card which was not supported up to 01/2006. I'm just wondering if any attempt to do so will become a total disaster since even the boxed kernel source is so full of errors.

any hint appreciated
cheers

Last edited by ColonelPanic; 06-15-2006 at 06:51 AM.
 
Old 06-15-2006, 06:50 AM   #2
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
when i encountered those kind of errors, I simply went back to 'make menuconfig' and unchecked the modules causing the error. Most of the time, I was simply tryin to compile old and unneeded modules in my kernel. Since then I have learnt to compile only those modules that were specifically needed by my system and nothing else. I have found this results in a compact kernel and the mem used when i just boot is also very low compared to the default ones also the machine I feel responds faster.
 
Old 06-15-2006, 07:07 AM   #3
ColonelPanic
Member
 
Registered: Jun 2006
Distribution: Ubuntu 7.10, Mandriva 2008
Posts: 40

Original Poster
Rep: Reputation: 15
Nice one prozac! I'll try that

Just a remark: I'm not a developer (I'm actually coming from SAP) and I know ABAP/4 (SAP language) well enough to know that things like 'undeclared arguments' are quite serious errors. - Actually ABAP won't even let you activate (release) the source code for compiling unless you have corrected all syntax and plausibility errors from dependent objects like includes, function modules etc. That's why it really baffles me that an OS :!: lets you release buggy source code into a compile run.

Anyway I'll try again.

cheers
 
Old 06-15-2006, 07:16 AM   #4
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
you know what i too have been thinking the same. 'unused variables', 'defined but not used' messages are really creepy. I am thinking then, the developers who wrote the drivers must have got lazy and decided not to correct those (after all they are just warnings!). It has got nothing to do with the kernel developers-they just include those drivers in the kernels. maybe somebody could explain more clearly.
 
Old 06-15-2006, 07:18 AM   #5
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
also try the output of 'lspci' and 'lsmod'. I have found them quite helpful in determining my exact devices and the modules they use.
 
Old 06-15-2006, 09:25 AM   #6
ColonelPanic
Member
 
Registered: Jun 2006
Distribution: Ubuntu 7.10, Mandriva 2008
Posts: 40

Original Poster
Rep: Reputation: 15
cheers prozac, much appreciated
 
Old 06-15-2006, 01:49 PM   #7
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Quote:
you know what i too have been thinking the same. 'unused variables', 'defined but not used' messages are really creepy
If you think about it though these aren't really a problem. All it means is that the programmer has defined a variable and then not used it. This kind of stuff probably happens all the time because of the rapid pace of development in the kernel and the use of #ifdef preprocessor statements to cope with all the different possible environments under which the software could run.

As for compiling your kernel try getting the kernel SRPM, not the kernel-source RPM. Goto any of the http or ftp mirrors listed for the main repo at easyurpmi.zarb.org and go up a few levels to find the SRPMS folder for main. In there you'll find the kernel SRPM, just download it, install it, make your changes and rebuild. http://qa.mandriva.com/twiki/bin/vie...ing_source_RPM

You could also just download the vanilla kernel source from kernel.org and at the make xconfig stage make sure to load the current config from the Mandriva kernel that you're using (look in /boot). If you do this do a make rpm instead of just make so that at the end it spits out a nice RPM that you can easily install.
 
Old 06-16-2006, 12:11 AM   #8
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Quote:
Originally Posted by tkedwards
If you think about it though these aren't really a problem. All it means is that the programmer has defined a variable and then not used it. This kind of stuff probably happens all the time because of the rapid pace of development in the kernel and the use of #ifdef preprocessor statements to cope with all the different possible environments under which the software could run.
Doesn't it waste memory like that? When you declare a variable, the system allocates memory the size of the variable, and when you don't use it, it lies there unused, wasted. What about freeing them afterwards, NO garbage collection, i suppose at that level.
Quote:
Originally Posted by tkedwards
As for compiling your kernel try getting the kernel SRPM, not the kernel-source RPM.
RPM? I have never downloaded kernel in RPMs. I am all the fine with using just the sources and I am not using Red Hat. I am a big source fan, I don't like packages.
 
Old 06-16-2006, 12:38 AM   #9
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Quote:
Doesn't it waste memory like that? When you declare a variable, the system allocates memory the size of the variable, and when you don't use it, it lies there unused, wasted. What about freeing them afterwards, NO garbage collection, i suppose at that level.
I think you're jumping to conclusions a bit. Garbage collection happens automatically when variables go out of scope, even in C/C++. The only way that you can cause memory to not be Garbage Collected and cause a memory leak is to assign a variable to point to a dynamically created object/variable and forget to free it before that variable goes out of scope. In other words in C/C++ you use new or malloc or whatever without a corresponding free call.

Therefore its impossible to have an unused variable that isn't Garbage Collected - you have to assign a variable to something (a new'ed/malloc'ed block of memory) first before you can cause a memory leak. As annoying and bad looking as those unused variables are all they really amount to is 32-bits (4 bytes) or so of wasted memory each. Even if there's say 1000 of them in your kernel that's only 4KB of wasted memory.

Of course I'm writing this off the top of my head so I could be wrong but I highly doubt that the kernel maintainers leave dozens or hundreds of memory leaks in their code that are visible as simple compiler warnings.

Quote:
RPM? I have never downloaded kernel in RPMs. I am all the fine with using just the sources and I am not using Red Hat. I am a big source fan, I don't like packages.
Maybe but I suggested the SRPM way as its the easiest, quickest and probably most failsafe way to get a kernel to recompile if you're not really sure what you're doing. I also suggested he try downloading he kernel from kernel.org and building it himself.
 
Old 06-16-2006, 12:53 AM   #10
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Quote:
Originally Posted by tkedwards
I think you're jumping to conclusions a bit.
I am sorry I am a little risky sometimes.

Quote:
Originally Posted by tkedwards
Garbage collection happens automatically when variables go out of scope, even in C/C++. The only way that you can cause memory to not be Garbage Collected and cause a memory leak is to assign a variable to point to a dynamically created object/variable and forget to free it before that variable goes out of scope. In other words in C/C++ you use new or malloc or whatever without a corresponding free call.

Therefore its impossible to have an unused variable that isn't Garbage Collected - you have to assign a variable to something (a new'ed/malloc'ed block of memory) first before you can cause a memory leak. As annoying and bad looking as those unused variables are all they really amount to is 32-bits (4 bytes) or so of wasted memory each. Even if there's say 1000 of them in your kernel that's only 4KB of wasted memory.
For static created variable its what you said and I don't think they would create problems. But what you are telling me about dynamically created ones are the issue I am thinking about now. 4Kb of wasted memory and you say its no probs! using malloc/calloc and then not freeing leads to mem leaks and is unforgivable in my concern. ofcourse, i don't know everything about programming yet but AFAIK its serious. In whatever programs i have written so far, I have tried my best to avoid this kind of mistakes. Memory bugs can make apps/oses crash. I've heard JAVA is so elegant because it automatically handles the garbage collection and hence reduces the chance of mem leaks (also abt the error handling but right now lets only talk abt garbage collections).
tkedwards, I am sorry but i am not convinced.
 
Old 06-16-2006, 08:24 AM   #11
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Quote:
using malloc/calloc and then not freeing leads to mem leaks and is unforgivable in my concern. ofcourse, i don't know everything about programming yet but AFAIK its serious. In whatever programs i have written so far, I have tried my best to avoid this kind of mistakes. Memory bugs can make apps/oses crash. I've heard JAVA is so elegant because it automatically handles the garbage collection and hence reduces the chance of mem leaks
I'm pointing out that its impossible to have an *unassigned* variable create a memory leak because to create a memory leak you first have to assign the variable to something. These 'unassigned' warnings are not memory leaks - the kernel developers go to great lengths to try and weed out memory leaks by auditing their code and using all sorts of tricky compiler options and debug programs to try and catch them. They would have long ago squashed any that showed up as simple compiler warnings.

Quote:
4Kb of wasted memory and you say its no probs!
4 bytes per variable is the default on 32-bit machines. That means if you have 1000 of these compiler warnings its still only 4KB, not 4KB per variable. 4KB is insignificant even when compared to the memory usage of the kernel, let alone the memory in your whole machine. I doubt you'd even have 1000 of these warnings but I gave that number to be safe and to show that it still is an insignificant amount of memory.
 
Old 06-16-2006, 11:35 AM   #12
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Quote:
Originally Posted by tkedwards
I'm pointing out that its impossible to have an *unassigned* variable create a memory leak because to create a memory leak you first have to assign the variable to something. These 'unassigned' warnings are not memory leaks -
I am not understanding. Its created and his its own address in the memory, Its not assigned to any value and yet its not a memory leak. can you explain a little bit more.
 
Old 06-16-2006, 01:44 PM   #13
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Excuse my very rusty C:
Code:
afunction {
   int j;
   int i = 0;
   while(i < 50)
   {
      /*do something*/
      i++;
   }
} /* both i and j go out of scope here and are properly 'garbage collected'*/
So each time this function runs it creates an unsed variable j, which as an int is 32 bits (4 bytes) on most machines.

Code:
averybadfunction {
   int j;
   j = malloc(1000);
   int i = 0;
   while(i < 50)
   {
      /*do something*/
      i++;
   }
} /* both i and j go out of scope here and are properly 'garbage collected'. 
However the block of dynamically allocated memory that was assigned to j is not freed and therefore becomes 'lost', ie. a memory leak. 
Note that since j is assigned a value the compiler will not throw an unassigned variable warning.*/
Each time this code runs it leaks memory but it does not leave any variables unassigned.

In other words its impossible to have an unassigned variable leak memory because as soon as you use malloc/calloc/new your variable is assigned a value:
Code:
j = malloc(1000);
All an unassigned variable will do is waste a very small amount of memory while that particular function that the variable is declared in is running, ie. when the variable is in scope. A memory leak is where you lose track of a dynamically allocated block of memory, ie. by doing a malloc() without a corresponding free() in C.

Last edited by tkedwards; 06-16-2006 at 01:49 PM.
 
Old 06-16-2006, 03:23 PM   #14
adilturbo
Member
 
Registered: Jun 2006
Location: morocco
Posts: 195

Rep: Reputation: 30
all what u have said was right,i want just to add an idea:
when using the new operator or whatever(dynamic allocation)then not using
the delete operator(freeing memory operators)the moment u quit the program
the O.S then freeing automatically the ammount of memory allocated.

i think u forgot somethings in ur code:

Code:
int* j;//j should be pointer
j =(int*) malloc(1000);//casting from void* to int*
thank u.
 
Old 06-18-2006, 03:18 AM   #15
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Quote:
Originally Posted by tkedwards
A memory leak is where you lose track of a dynamically allocated block of memory, ie. by doing a malloc() without a corresponding free() in C.
I get it this is not the case with those compiler errors. The compiler won't catch these kind of errors right. These are created on run-time and any error hence forth relating to these abandoned variable ought to be catched by the os (if the program doesn't specifically handles it using free()). and the kernel does a good job of catching and freeing such hence its no probs actually.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loads of error messages after kernel recompile 2.6.16.16 eeyore22 Ubuntu 5 02-07-2008 12:20 PM
fsck errors after kernel recompile tgo Linux - Kernel 2 05-26-2006 06:51 PM
Errors after Kernel Recompile alagenchev Linux - General 5 10-17-2005 10:19 AM
Errors after kernel recompile. springshades Linux - Software 8 07-12-2005 04:23 AM
2 sound card errors after kernel recompile. Need newbie help LearningToSlack Linux - Newbie 2 11-10-2003 04:46 PM


All times are GMT -5. The time now is 12:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration