Chinaunix首页 | 论坛 | 博客
  • 博客访问: 124548
  • 博文数量: 35
  • 博客积分: 2085
  • 博客等级: 大尉
  • 技术积分: 395
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-03 10:42
文章分类

全部博文(35)

文章存档

2012年(1)

2011年(3)

2010年(15)

2009年(8)

2008年(8)

我的朋友

分类: LINUX

2009-09-09 16:00:07

内核中的strlen不检查字符串是否为NULL。

size_t strlen(const char *s)
{
        const char *sc;

        for (sc = s; *sc != '\0'; ++sc)
                /* nothing */;
        return sc - s;
}
EXPORT_SYMBOL(strlen);

所以调用strlen的函数必须保证传入的字符串不为空,否则就会出现类似下面的Oops.

root@localhost:/root> Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT
Modules linked in:
CPU: 0    Not tainted  (2.6.27.24-WR3.0zz_standard-00002-gf45072a #2)
PC is at strlen+0x18/0x2c
LR is at rndis_msg_parser+0x3b4/0x7f4
pc : []    lr : []    psr: 20000093
sp : c03b7d70  ip : c03b7d80  fp : c03b7d7c
r10: c7b3a3c0  r9 : fee00500  r8 : c7b3a3d4
r7 : c7b3a3ec  r6 : c7b3a3d4  r5 : c03edb08  r4 : 00000000
r3 : c03edb08  r2 : 00000000  r1 : c03edb38  r0 : 00000000
Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005317f  Table: c7aa4000  DAC: 00000017
Process swapper (pid: 0, stack limit = 0xc03b6268)
Stack: (0xc03b7d70 to 0xc03b8000)
7d60:                                     c03b7da4 c03b7d80 c01f9934 c017de58
7d80: c79d1140 c79d1480 c780905c 00000000 fee00500 fee00400 c03b7dcc c03b7da8
7da0: c01f8dd0 c01f9590 c7843240 0000004c c79d1140 c79d1480 00000000 c780905c
7dc0: c03b7dfc c03b7dd0 c01f39dc c01f8db4 c03b7e18 00014c00 c03e09ac c7809b28
7de0: c7809000 c79d1498 c7809000 c79d1480 c03b7e14 c03b7e00 c01f214c c01f38bc
7e00: 00000b20 c79d1498 c03b7e6c c03b7e18 c01f25ec c01f2140 0aba9500 000001a9
7e20: 0a22d268 000001a9 c03b7e74 c7809040 c0061518 00210b78 00000000 c780004c
7e40: 0a22d268 00000008 c7809000 00000000 0000003a 00000099 fee00000 000000f0
7e60: c03b7ea4 c03b7e70 c01f1510 c01f246c c006162c c00614e4 00000000 000001a9
7e80: 00000001 c7809000 00080001 0000003a 00000001 10000000 c03b7eec c03b7ea8
7ea0: c01f1d94 c01f1304 00000001 c03b6000 c03b7efc c03b7ec0 40000013 c003bafc
7ec0: 00000015 c7812660 00000000 00000000 0000003a 00000001 c03b6000 c0026234
7ee0: c03b7f0c c03b7ef0 c0071eec c01f1bec c03c0448 0000003a c03b6000 c7812660
7f00: c03b7f2c c03b7f10 c007343c c0071eb8 c03c0448 0000003a 00000000 00000002
7f20: c03b7f4c c03b7f30 c002c044 c0073310 ffffffff febd0000 04000000 00000002
7f40: c03b7fa4 c03b7f50 c002c8a8 c002c010 00000000 0005317f 0005217f 60000013
7f60: c002e390 c03b6000 c0029330 c03ba538 c0026268 41069265 c0026234 c03b7fa4
7f80: 600000d3 c03b7f98 c002e3d8 c002e3e4 60000013 ffffffff c03b7fbc c03b7fa8
7fa0: c002e364 c002e3a0 c03e7e38 c03d974c c03b7fcc c03b7fc0 c02f9424 c002e334
7fc0: c03b7ff4 c03b7fd0 c0008988 c02f93c8 c0008494 00000000 00000000 c0029334
7fe0: 00053175 c03d9c60 00000000 c03b7ff8 c0008034 c000871c 00000000 00000000
Backtrace:
[] (strlen+0x0/0x2c) from [] (rndis_msg_parser+0x3b4/0x7f4)
[] (rndis_msg_parser+0x0/0x7f4) from [] (rndis_command_complete+0x2c/0x74)
[] (rndis_command_complete+0x0/0x74) from [] (musb_g_giveback+0x130/0x15c)
 r6:c780905c r5:00000000 r4:c79d1480
[] (musb_g_giveback+0x0/0x15c) from [] (musb_g_ep0_giveback+0x1c/0x28)
 r7:c79d1480 r6:c7809000 r5:c79d1498 r4:c7809000
[] (musb_g_ep0_giveback+0x0/0x28) from [] (musb_g_ep0_irq+0x190/0x86c)
 r5:c79d1498 r4:00000b20
[] (musb_g_ep0_irq+0x0/0x86c) from [] (musb_interrupt+0x21c/0x4c0)
[] (musb_interrupt+0x0/0x4c0) from [] (da8xx_interrupt+0x1b8/0x2a0)
[] (da8xx_interrupt+0x0/0x2a0) from [] (handle_IRQ_event+0x44/0x84)
[] (handle_IRQ_event+0x0/0x84) from [] (handle_edge_irq+0x13c/0x1ac)
 r7:c7812660 r6:c03b6000 r5:0000003a r4:c03c0448
[] (handle_edge_irq+0x0/0x1ac) from [] (__exception_text_start+0x44/0x60)
 r7:00000002 r6:00000000 r5:0000003a r4:c03c0448
[] (__exception_text_start+0x0/0x60) from [] (__irq_svc+0x48/0x98)
Exception stack(0xc03b7f50 to 0xc03b7f98)
7f40:                                     00000000 0005317f 0005217f 60000013
7f60: c002e390 c03b6000 c0029330 c03ba538 c0026268 41069265 c0026234 c03b7fa4
7f80: 600000d3 c03b7f98 c002e3d8 c002e3e4 60000013 ffffffff                  
 r7:00000002 r6:04000000 r5:febd0000 r4:ffffffff
[] (default_idle+0x0/0x5c) from [] (cpu_idle+0x40/0x6c)
[] (cpu_idle+0x0/0x6c) from [] (rest_init+0x6c/0x80)
 r5:c03d974c r4:c03e7e38
[] (rest_init+0x0/0x80) from [] (start_kernel+0x27c/0x2e0)
[] (start_kernel+0x0/0x2e0) from [] (__enable_mmu+0x0/0x2c)
 r5:c03d9c60 r4:00053175
Code: e24cb004 e1a02000 ea000000 e2800001 (e5d03000)
Kernel panic - not syncing: Fatal exception in interrupt

阅读(1233) | 评论(0) | 转发(0) |
0

上一篇:Illegal instruction

下一篇:kgdboe调试方法

给主人留下些什么吧!~~