HASH_FIND_STR giving segfault

297 views
Skip to first unread message

Saroj kumar Panda

unread,
Aug 26, 2014, 2:21:05 AM8/26/14
to uth...@googlegroups.com
Hi,
      I am using uthash for a long time. But for the last two days am getting a strange result. I am clueless about it.

Let me elaborate

The function am using is
      int is_exist_in_hash(char *key) {
                          struct internal_data_buff_t *s = NULL;

                          if (pthread_rwlock_rdlock(&lock) != 0) log4c_category_log(mycat, LOG4C_PRIORITY_DEBUG,"cannot lock");
                              HASH_FIND_STR( hash_int, key, s );  /* s: output pointer */
                           pthread_rwlock_unlock(&lock);

        if(s)
            return 1;
         else
             return 0;
}




the structure for the same is

struct internal_data_buff_t
{
        char sno[32];
        char url[4048];
        int status_flag;
        int thrd_index;
        UT_hash_handle hh;
};



It works but running after multiple times it give segfault on the HASH_FIND_STR

in the gdb it shows like

Program terminated with signal 11, Segmentation fault.
112        HASH_FIND_STR( hash_int, key, s );  /* s: output pointer */
(gdb) bt
#0  0x0000000000407c3b in is_exist_in_hash (key=0x41c07fc0 "3121001328") at Hash_Operation.c:112



I am not sure why it is giving segfault afer certain run . Can anybody please help me on this.

Thanks
Saroj

Troy D. Hanson

unread,
Aug 27, 2014, 9:27:22 AM8/27/14
to uth...@googlegroups.com
Can you confirm you initialized hash_int to NULL before you ever use it? I'd also suggest running it under valgrind to see if it sees the error.

--
You received this message because you are subscribed to the Google Groups "uthash" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uthash+un...@googlegroups.com.
To post to this group, send email to uth...@googlegroups.com.
Visit this group at http://groups.google.com/group/uthash.
For more options, visit https://groups.google.com/d/optout.

biswa...@gmail.com

unread,
May 24, 2017, 12:19:10 AM5/24/17
to uthash
Did you find a root cause to the set fault? I have the same issue
Reply all
Reply to author
Forward
0 new messages