LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rmmod segfaulting and causing lsmod to hang withh 2.6.3 kernel (https://www.linuxquestions.org/questions/linux-software-2/rmmod-segfaulting-and-causing-lsmod-to-hang-withh-2-6-3-kernel-148979/)

Kurt M. Weber 02-21-2004 10:04 PM

rmmod segfaulting and causing lsmod to hang withh 2.6.3 kernel
 
OK, I'm getting into kernel devel, and to learn the API I've got a useless module I'm writing. Right now, all it does is printk something on load and something else on unload. I can insmod it fine, but when I rmmod it, it simply segfaults. After I do rmmod, anytime I run lsmod, it simply hangs and I cannot kill it! I cannot kill it! The damned beast simply WILL NOT DIE! DIE, BEAST, DIE! DIE! BWA-HA-HA-HA-HA!

But yeah, rmmod and lsmod are acting retarded. Any ideas?

trickykid 02-21-2004 10:06 PM

I'm not sure if this is it but in the latest 2.6.x kernel series, you compile in support to remove modules, etc. Do you have such support?

Kurt M. Weber 02-21-2004 10:10 PM

Yes, I did that.

Earlier I was trying to remove the same module, and it explicitly told me that I hadn't compiled support for module unloading in. So I recompiled with unloading support, and now things just go all to hell rather than a nice, polite error message :)

Oliv' 02-22-2004 10:55 AM

What's your source code? Have you correctly initialize each struct?

Kurt M. Weber 02-24-2004 10:42 PM

So far, this is it (eventually, it's going to be a driver for a device similar to /dev/zero, except it spits out 'z's instead of '0's):
Code:

#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int __init init_zdrv(void) {
    printk(KERN_DEBUG "Z driver loaded\n");
    return 0;
}
static void __exit exit_zdrv(void) {
  printk(KERN_DEBUG "Z driver unloaded\n");
}
module_init(init_zdrv);
module_exit(exit_zdrv);


Oliv' 02-25-2004 11:51 AM

I test this code with my 2.4.24 kernel and everything went fine. Note that I have to add "#include <linux/kernel.h>" for printk purposes and I have also removed "#incude <linux/config.h> which was not necessary for me.
I also look about "Migrating device drivers to Linux kernel 2.6" and your code seems to be good. So the question is: do you have already had such behaviour with other modules with your 2.6 kernel? (I suppose the answer is no, but we never know)
the last advice I can give you to debug it is to use UML (User Mode Linux of course :) )


All times are GMT -5. The time now is 05:44 AM.