Help interpret gdb: segfault in function

I am trying to debug segfault and I have this output from gdb:

(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x08048af9 in parse_option_list (ptr=0x6f72505f <Address 0x6f72505f out of bounds>, box_name=0x696d6978 <Address 0x696d6978 out of bounds>, option_list=0x313a7974, 
    num_elements=0x33313532) at submit.c:125
125                         memcpy(&(option_list[(*num_elements)].value), value, 24);
(gdb) p num_elements
$15 = (int *) 0x33313532
(gdb) p *num_elements
Cannot access memory at address 0x33313532
(gdb) 

It seems to me that something in memcpy () goes haywire. But I can’t understand what the problem is, since this line refers to so many variables.

Can someone help figure out what the string tells me 0x8048af9 in parse_option_list...?

My function signature:

int parse_option_list(char *ptr, char *box_name,
   struct option_list_values *option_list, int *num_elements)

And this may be useful:

struct option_list_values {
    char value[24];
    char name[24];
};

In addition, variables valueand nameare not segfault (but if you think they are, I can post the code that sets these values.) But right now, if I can understand this conclusion the gdb, I'll be happy as a clam! Thanks!

+3
source share
3 answers

. ASCII - ( , little-endian, ):

ptr = 0x6f72505f = "_Pro"
box_name = 0x696d6978 = "ximi"
option_list = 0x313a7974 = "ty:1"
num_elements = 0x33313532 = "2513"

"_Proximity:12513" - , , - - , , .

+14

0x8048af9 - - , , SEGFAULT.

, option_list [(* num_elements)]. ? , , -, .

num_elements - option_list, option_list [(* num_elements)] .

+1

ptr = 0x6f72505f - Address 0x6f72505f outside This is the useful part in this case The first entry in parse_option_list is not valid. Perhaps an uninitialized pointer.

0
source

Source: https://habr.com/ru/post/1717034/


All Articles