如何卸载一个出现段错误的模块

99 views
Skip to first unread message

孟阿龙

unread,
Mar 26, 2010, 12:34:10 AM3/26/10
to 西邮Linux兴趣小组
大家好,我在写模块测试时,不小心写了一个含有段错误的模块test.ko,模块在编译时没有错误。我在加载模块时出现段错误的提示。
我尝试用  rmmod test  卸载出现如下提示:ERROR: Module test is in use
我用  rmmod -f test   卸载时提示信息如下:ERROR: Removing 'test': Device or resource busy
不知道这个模块怎样能够卸载下来呢?


刘洋

unread,
Mar 26, 2010, 1:37:45 AM3/26/10
to 孟阿龙, 西邮Linux兴趣小组
On Fri, Mar 26, 2010 at 12:34:10PM +0800, �ϰ��� wrote:
> ��Һã�����дģ�����ʱ����С��д��һ�����жδ����ģ��test.ko��ģ���ڱ���ʱû�д������ڼ���ģ��ʱ���ֶδ������ʾ��
> �ҳ����� rmmod test ж�س���������ʾ��ERROR: Module test is in use
> ���� rmmod -f test ж��ʱ��ʾ��Ϣ����:ERROR: Removing 'test': Device or resource
> busy
> ��֪�����ģ�������ܹ�ж�������أ�
>

���ģ�������һЩ���ɻָ��Ĵ��󣬿�����ж�ز������ġ�

Américo Wang

unread,
Mar 26, 2010, 1:48:59 AM3/26/10
to 孟阿龙, 西邮Linux兴趣小组
2010/3/26 孟阿龙 <boya...@gmail.com>:

> 大家好,我在写模块测试时,不小心写了一个含有段错误的模块test.ko,模块在编译时没有错误。我在加载模块时出现段错误的提示。

什么是“含有段错误的模块”?内核里面没有段错误,只有Oops,panic等。
请贴出相关的错误信息。

> 我尝试用  rmmod test  卸载出现如下提示:ERROR: Module test is in use
> 我用  rmmod -f test   卸载时提示信息如下:ERROR: Removing 'test': Device or resource
> busy
> 不知道这个模块怎样能够卸载下来呢?
>

同上,请贴出/var/log/messages里和这相关的信息。

孟阿龙

unread,
Mar 26, 2010, 3:36:48 AM3/26/10
to Américo Wang, 西邮Linux兴趣小组
下面是我加载模块时出现的错误:

along@along-laptop:~/code/modules/test$ sudo insmod test_segment.ko 
段错误
along@along-laptop:~/code/modules/test$ sudo rmmod test_segment
ERROR: Module test_segment is in use
along@along-laptop:~/code/modules/test$ sudo rmmod -f test_segment
ERROR: Removing 'test_segment': Device or resource busy

 
下面是我加载模块时日志文件里的信息:
Mar 26 15:32:03 along-laptop kernel: [12283.117063] BUG: unable to handle kernel NULL pointer dereference at 00000000
Mar 26 15:32:03 along-laptop kernel: [12283.117074] IP: [<f911f026>] list_init+0x6/0x20 [test_segment]
Mar 26 15:32:03 along-laptop kernel: [12283.117084] *pde = 00000000 
Mar 26 15:32:03 along-laptop kernel: [12283.117092] Oops: 0000 [#3] SMP 
Mar 26 15:32:03 along-laptop kernel: [12283.117098] last sysfs file: /sys/devices/LNXSYSTM:00/device:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/energy_full
Mar 26 15:32:03 along-laptop kernel: [12283.117106] Modules linked in: test_segment(+) test_seg(+) test(+) binfmt_misc ppdev bridge stp bnep vboxnetadp vboxnetflt vboxdrv input_polldev joydev lp parport snd_hda_intel snd_pcm_oss snd_mixer_oss snd_pcm arc4 snd_seq_dummy snd_seq_oss ecb snd_seq_midi snd_rawmidi snd_seq_midi_event ath5k snd_seq snd_timer snd_seq_device mac80211 sis190 snd fglrx(P) psmouse video uvcvideo mii asus_laptop pcspkr soundcore snd_page_alloc sis_agp agpgart serio_raw cfg80211 output compat_ioctl32 videodev v4l1_compat led_class usbhid usb_storage fbcon tileblit font bitblit softcursor [last unloaded: list1]
Mar 26 15:32:03 along-laptop kernel: [12283.117200] 
Mar 26 15:32:03 along-laptop kernel: [12283.117206] Pid: 14275, comm: insmod Tainted: P      D    (2.6.28-15-generic #52-Ubuntu) F5SL              
Mar 26 15:32:03 along-laptop kernel: [12283.117212] EIP: 0060:[<f911f026>] EFLAGS: 00210292 CPU: 1
Mar 26 15:32:03 along-laptop kernel: [12283.117217] EIP is at list_init+0x6/0x20 [test_segment]
Mar 26 15:32:03 along-laptop kernel: [12283.117222] EAX: f63fa000 EBX: 00000000 ECX: f911f300 EDX: 00000001
Mar 26 15:32:03 along-laptop kernel: [12283.117226] ESI: f911f020 EDI: 00000000 EBP: f63fbe24 ESP: f63fbe1c
Mar 26 15:32:03 along-laptop kernel: [12283.117230]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Mar 26 15:32:03 along-laptop kernel: [12283.117236] Process insmod (pid: 14275, ti=f63fa000 task=d95f1920 task.ti=f63fa000)
Mar 26 15:32:03 along-laptop kernel: [12283.117239] Stack:
Mar 26 15:32:03 along-laptop kernel: [12283.117242]  e8fc23f0 f63fbe30 f63fbf8c c010111e f63fbe50 c020c455 c020bc23 f63fbe50
Mar 26 15:32:03 along-laptop kernel: [12283.117256]  c020bc9f e8fc2ae0 f63fbe5c 00000002 c151f0c0 c06cdb80 00002400 f63fbe80
Mar 26 15:32:03 along-laptop kernel: [12283.117269]  00200206 00000105 00000002 00000000 00200206 00000001 00200286 e8d5a040
Mar 26 15:32:03 along-laptop kernel: [12283.117285] Call Trace:
Mar 26 15:32:03 along-laptop kernel: [12283.117288]  [<c010111e>] ? _stext+0x2e/0x170
Mar 26 15:32:03 along-laptop kernel: [12283.117297]  [<c020c455>] ? sysfs_addrm_finish+0x15/0xf0
Mar 26 15:32:03 along-laptop kernel: [12283.117307]  [<c020bc23>] ? sysfs_add_one+0x13/0x50
Mar 26 15:32:03 along-laptop kernel: [12283.117313]  [<c020bc9f>] ? sysfs_addrm_start+0x3f/0xa0
Mar 26 15:32:03 along-laptop kernel: [12283.117320]  [<c01a935c>] ? __vunmap+0x9c/0xe0
Mar 26 15:32:03 along-laptop kernel: [12283.117330]  [<c01a935c>] ? __vunmap+0x9c/0xe0
Mar 26 15:32:03 along-laptop kernel: [12283.117346]  [<c01a93f1>] ? vfree+0x21/0x30
Mar 26 15:32:03 along-laptop kernel: [12283.117352]  [<c016413d>] ? load_module+0x103d/0x1050
Mar 26 15:32:03 along-laptop kernel: [12283.117373]  [<c01641d8>] ? sys_init_module+0x88/0x1b0
Mar 26 15:32:03 along-laptop kernel: [12283.117380]  [<c01bb90a>] ? sys_close+0x7a/0xc0
Mar 26 15:32:03 along-laptop kernel: [12283.117387]  [<c0103f6b>] ? sysenter_do_call+0x12/0x2f
Mar 26 15:32:03 along-laptop kernel: [12283.117393]  [<c0500000>] ? rwsem_down_failed_common+0xa0/0x1b0
Mar 26 15:32:03 along-laptop kernel: [12283.117405] Code: <a1> 00 00 00 00 c7 04 24 73 f0 11 f9 89 44 24 04 e8 13 f1 3d c7 31 
Mar 26 15:32:03 along-laptop kernel: [12283.117440] EIP: [<f911f026>] list_init+0x6/0x20 [test_segment] SS:ESP 0068:f63fbe1c
Mar 26 15:32:03 along-laptop kernel: [12283.117452] ---[ end trace 0473ec4360e72f0d ]---

我现在知道模块里出现的问题是因为我访问了一个空指针造成的。但是现在无法卸载掉这个模块。

Américo Wang

unread,
Mar 26, 2010, 3:44:24 AM3/26/10
to 孟阿龙, 西邮Linux兴趣小组
2010/3/26 孟阿龙 <boya...@gmail.com>:
>
> 我现在知道模块里出现的问题是因为我访问了一个空指针造成的。但是现在无法卸载掉这个模块。
>

既然oops是你期望的,无法卸载也是。
oops之后系统处于不稳定的状态,无法卸载不奇怪,你需要重启。

孟阿龙

unread,
Mar 26, 2010, 3:59:15 AM3/26/10
to Américo Wang, 西邮Linux兴趣小组
谢谢了,看来只能是重启了。

孟阿龙

unread,
Mar 27, 2010, 9:03:20 PM3/27/10
to main.c, 西邮Linux兴趣小组


在 2010年3月28日 上午2:08,main.c <66kn...@gmail.com>写道:
从哪个地方看出是空指针呢~~

我在程序里有这样几条语句;
struct tenode *pos;
pos = NULL;
printk( KERN_ALERT"%d", p->id );
很明显引用了空指针。
另外从上面日志的第一行也可以看出来。

--
要退订此论坛请发邮件至 xiyoulinux-...@googlegroups.com
更多选项: http://groups.google.com/group/xiyoulinux?hl=zh-CN
提问前建议您阅读:http://www.xiyoulinux.cn/blog/?p=64
也请查看我们的FAQ:http://xiyoulinux.cn/wiki/index.php?title=FAQ
 
To unsubscribe from this group, send email to xiyoulinux+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


SUN

unread,
Apr 29, 2010, 1:03:38 AM4/29/10
to 孟阿龙, linux小组论坛
我也是最近遇到这个问题,还是装一个虚拟机吧,还是 这样比较好……

自强不息,厚德载物,天道酬勤,求实奋进……
Reply all
Reply to author
Forward
0 new messages