看到一个crash dump
[17293.834304:1] kernel BUG at mm/slab.c:3072!
[17293.834311:1] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
[17293.834319:1] Modules linked in: memalloc hx280enc hx170dec mali ump
[17293.834338:1] CPU: 1 Not tainted (3.4.0-g227f4c6-dirty #1)
[17293.834359:1] PC is at cache_free_debugcheck+0x234/0x388
[17293.834369:1] LR is at cache_free_debugcheck+0x90/0x388
[17293.834379:1] pc : [<c00adc74>] lr : [<c00adad0>] psr: 20000093
[17293.834384:1] sp : d799de58 ip : d799de58 fp : d799de9c
[17293.834392:1] r10: 00000000 r9 : 000ec83d r8 : ffc00000
[17293.834400:1] r7 : c0222f30 r6 : 001328b8 r5 : c883e000 r4 : ee0001c0
[17293.834408:1] r3 : 00100000 r2 : dc000004 r1 : 00000001 r0 : c883e000
当前出问题的位置很明确:
[17293.834304:1] kernel BUG at mm/slab.c:3072!
PC is at cache_free_debugcheck+0x234/0x388
3072: BUG_ON(objnr >= cachep->num);
但是,反汇编函数cache_free_debugcheck此时对应的指令是:
0xc00adc74 <cache_free_debugcheck+564>: ; <UNDEFINED> instruction: 0xe7f001f2
“<UNDEFINED> instruction: 0xe7f001f2”
难道是对应的指令有问题?RAM突然出现问题啦?
跟踪一下BUG_ON的实现,就是使用了undefined instruction 异常,上面的现象是正常的
3072: BUG_ON(objnr >= cachep->num);
include/asm-generic/bug.h
#ifndef HAVE_ARCH_BUG_ON
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
#endif
arch/arm/include/asm/bug.h
/*
* Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
* We need to be careful not to conflict with those used by other modules and
* the register_undef_hook() system.
*/
#ifdef CONFIG_THUMB2_KERNEL
#define BUG_INSTR_VALUE 0xde02
#define BUG_INSTR_TYPE ".hword "
#else
#define BUG_INSTR_VALUE 0xe7f001f2
#define BUG_INSTR_TYPE ".word "
#endif
#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
#define _BUG(file, line, value) __BUG(file, line, value)
#define __BUG(__file, __line, __value) \
do { \
asm volatile(BUG_INSTR_TYPE #__value); \
unreachable(); \
} while (0)