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打印


我的问题是:

  • 我从不改变这个缓冲区的地址。出于存储目的,我使用尾部偏移量(如*(cb->buffer+cb->tail_offset)=ch;并增加尾部_偏移量,如cb->tail_offset=(++cb->tail_offset)%cb->容量

  • 我很好奇容量、首尾偏移量和尾偏移量的内容。请看紧急订单

  • 崩溃--cir_调试_日志 cir_调试_日志:$7:缓冲区--0xac3d83097f040056,容量--67131560, 水头偏移量——2303465086, 尾翼偏移量——1156221409,
    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*.