After allocating memory for some variables, segfault is often to happen, due to the same reason: Address 0x1cd00000103 out of bounds
It is welcome to recommend some treatments. Thanks
e.g.
is_done = 0x1cd00000103 <Address 0x1cd00000103 out of bounds>,
hood = 0x23c00000247,
c = 0x1a900000149 <Address 0x1a900000149 out of bounds>,
site = 0x40a000004fc,
site2 = 0x3ba0000059f,
des = 0x47200000199 <Address 0x47200000199 out of bounds>,
asc = 0x47500000056 <Address 0x47500000056 out of bounds>,
But, use of these varialbes in code will lead to segfaults, e.g. if(node->is_done) { --- }
check these varialbes, those showing 'address 0x1cd00000103 out of bounds' will finally lead to segments
I should remind that some nodes but not all the nodes in a tree will give segfaults when checking if(node->is_done)
It is said that unsuccessful initialization is the source of 'Address 0x1cd00000103 out of bounds'. Concretely speaking, how to avoid such unsuccessful initialization occur in some nodes?
I think you are confused about what you are trying to do! In the examples above, you are allocating memory one address at a time and storing the pointers in your structure inside "node". So node->hood presumably holds a pointer to 4 (or 8) bytes (the size of "double").
Also, where did you allocate memory for node? Presumably you have:
Right!! these are pointers. What does 'out of bounds' mean? More important, how to avoid it? Clearly null checking can not make effect in this respect.
Program received signal SIGSEGV, Segmentation fault.
520 while( tr->root->is_done) { ----}
(gdb) p tr->root->is_done
$2 = (int *) 0x3f500000539 <Address 0x3f500000539 out of bounds>
(gdb) pt tr->root->is_likelihood_done
type = int *
They are pointers. This is sure. But there is some mistakes in the code I gave before. The assignment should use * before the pointers. I am sorry for carelessness when posted. But when checking with 'while ( *( tr->root->is_done ) )', the same segfault happen. And corresponding pinter address still be 'out of bounds". In my code, such statements exist.
This is a package coded by a previous member. He habits to use such structure for varialbes which control execution. A large package means that it is not easy to change all the strutures of this kind.
What's more, I think this is really a topic worth discusssion.