I’m using a double-linked list and getting some odd performance regarding edge cases when we’re dealing with previous or next pointers that are null. GDB returns the following error:
Program received signal SIGSEGV, Segmentation fault.
0x0804a9c1 in DLinkDelete (delete=0xd8c9d33c) at test.c:213
213 if (prevdl && prevdl->next)
(gdb) p prevdl
$39 = (DoubleLink *) 0xdadadada
(gdb) p prevdl->next
$40 = (void *) 0x0
DoubleLink is a struct with the following format:
typedef struct
{
void *next;
void *prev;
} DoubleLink;
Why would a segmentation fault be raised here?
Presumably
prevdlpoints to invalid memory ? Come on, does0xdadadadareally look like a valid address to you ? “It’s too idiotic to be schizophrenic“.