Я получаю следующий отчет об ошибке от Valgrind при запуске моей программы, особенно в этой функции:
==1011== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1011==
==1011== Process terminating with default action of signal 11 (SIGSEGV)
==1011== Access not within mapped region at address 0x1FFE801FF8
==1011== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1011== at 0x400D6F: searchGNode (genomefunc.c:42)
==1011== If you believe this happened as a result of a stack
==1011== overflow in your program's main thread (unlikely but
==1011== possible), you can try to increase the size of the
==1011== main thread stack using the --main-stacksize= flag.
==1011== The main thread stack size used in this run was 8388608.
==1011== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1011==
==1011== Process terminating with default action of signal 11 (SIGSEGV)
==1011== Access not within mapped region at address 0x1FFE801FC8
==1011== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1011== at 0x4A24710: _vgnU_freeres (vg_preloaded.c:59)
==1011== If you believe this happened as a result of a stack
==1011== overflow in your program's main thread (unlikely but
==1011== possible), you can try to increase the size of the
==1011== main thread stack using the --main-stacksize= flag.
==1011== The main thread stack size used in this run was 8388608.
Это рассматриваемая функция:
41 GNode * searchGNode ( GNode * root, GNode * newnode, int * flag,int k,GNode * last)
42 {
43 GNode * found = NULL;
44 if (root == NULL)
45 {
46 return found;
47 }
48 if ( strcmp(root->key,newnode->key) == 0)
49 {
50 return root; // this is the match , we have found that this node exists in the graph
51 }
52 found = searchGNode(root->one,newnode,flag,k,last); // search first pointer
53 if (found != NULL)
54 {
55 //printf("found duplicate: %s,last: %s \n",newnode->key,last->key);
56 *flag = 1;
57 insertGNode(last,found); // insert if we find
58 return found;
59 }
60 found = searchGNode(root->two,newnode,flag,k,last);
61 if (found != NULL)
62 {
63 *flag = 1;
64 insertGNode(last,found);
65 return found;
66 }
67 found = searchGNode(root->three,newnode,flag,k,last);
68 if (found != NULL)
69 {
70 *flag = 1;
71 insertGNode(last,found);
72 return found;
73 }
74 found = searchGNode(root->four,newnode,flag,k,last);
75 if (found != NULL)
76 {
77 *flag = 1;
78 insertGNode(last,found);
79 return found;
80 }
81 return NULL;
82 }
И это Gnode's struct:
typedef struct GNode{
char key [MAX_KMER_LEN]; // MAX_KMER_LEN is defined as 16
struct GNode* one;
struct GNode* two;
struct GNode* three;
struct GNode* four;
int in;
int out;
}GNode;
Есть ли где-нибудь место, где можно увидеть бесконечную рекурсию или переполнение стека? Поскольку моя функция кажется мне прекрасной, я не могу понять, что происходит. Спасибо