I have a function that I'm using to shuffle the nodes in a linked list. It takes a pointer to the head node and the length of the list as an argument. It works fine, repeatedly, on all kinds of lists UNLESS the list length is slightly over 1 million (which is several hundred megs out of 2G local RAM). Then the whole program seg faults immediately after the shuffle is called. gdb will just point to the first real instruction in the function as the culprit:
gdb sez:Code:node *shuffle (node *head, int len) { int i, X, r; node *ray[len], *tmp; printf("shuffle()..."); fflush(stdout);
Program received signal SIGSEGV, Segmentation fault.
0x0000000000402d2b in shuffle (head=0x605010, len=1050000) at linklist.c:543
543 printf("shuffle()..."); fflush(stdout);
1,000,000 okay. 1,050,000 no good! Note that shuffle()... does not even print!