C 地址越界
我正在初始化它的驱动程序加载时间,并在整个过程中跟踪它的地址,这是不变的C 地址越界,c,kernel,C,Kernel,我正在初始化它的驱动程序加载时间,并在整个过程中跟踪它的地址,这是不变的 typedef struct circular_buffer char *buffer; unsigned capacity; unsigned head_offset; unsigned tail_offset; volspin_t vxl_lock; extern struct circular_buffer cir_debug_log;
typedef struct circular_buffer
char *buffer;
unsigned capacity;
unsigned head_offset;
unsigned tail_offset;
volspin_t vxl_lock;
extern struct circular_buffer cir_debug_log;
但不知何故,我无法通过崩溃打印cir_debug_log->buffer中的字符串。它正确地复制了我检查过的缓冲区中的字符串。
cb->buffer的地址没有改变,但在崩溃中它显示了不同的地址
这是我的字符串,也应该通过crash打印
我的问题是:
vxl_lock--000你能解释一下“cb->buffer的地址没有改变,但在崩溃中它显示了不同的地址”是什么意思吗?你的代码的某些部分(或者-不太可能-内核中的其他驱动程序)可能会损坏
cir_调试日志
并用垃圾覆盖buffer
指针值。这个值(以0x56结尾)看起来有点奇怪。这是我的问题::1.我从不更改此缓冲区的地址。出于存储目的,我使用尾部偏移量(如*(cb->buffer+cb->tail\U offset)=ch;并增加尾部偏移量,如此cb->tail\U offset=(++cb->tail\U offset)%cb->capacity;2.我对容量、head_offset和tail_offset的内容很好奇。请看崩溃o/p。崩溃>cir_debug_log cir_debug_log=7={buffer=0xac3d83097f040056,capacity=67131560,head_offset=2303465086,tail_offset=1156221409,vxlock={}当然,看起来结构已经被破坏了。考虑到你malloc'ed 25000字节,这些值没有意义。不幸的是,我没有任何关于内核驱动程序调试的提示。谢谢你的努力。
typedef struct circular_buffer
char *buffer;
unsigned capacity;
unsigned head_offset;
unsigned tail_offset;
volspin_t vxl_lock;
extern struct circular_buffer cir_debug_log;
cb->buffer : mzalloc_sleep(25000* sizeof(char));
cb_push_data: end trying to print messgae with cb->buffer contains buffer_content=
"Purging msg accumulated during reonline operation "
I see you have this code displayed, which is missing most of the initialization
and what is displayed contains some syntax errors
typedef struct circular_buffer
{ // this line is missing
char *buffer;
unsigned capacity;
unsigned head_offset;
unsigned tail_offset;
volspin_t vxl_lock;
} // this line is missing
extern struct circular_buffer cir_debug_log;
// where is this declaration of 'cb'?
struct circular_buffer *cb = cir_debug_log;
// where is the initialization of the other fields?
cb->capacity = 25000 * sizeof(char);
cb->head_offset = 0;
cd->tail_offset = 0;
// this has a syntax error: ':' should be '='
cb->buffer : mzalloc_sleep(25000* sizeof(char));
BTW:
it is normal to write to the *head* and read from the *tail*.