Problem with confd_hash2str


I am trying to use confd_hash2str. But it always return invalid address.

I enabled confd trace and i could see that MAAPI_LOAD_HASH_DB loading is done.
strong text
But when i do tmpName = confd_hash2str(cur->tag) here cur->tag is 1154239108.

(gdb) p tmpName
$4 = 0xfffffffff00288a0  Address 0xfffffffff00288a0 out of bounds

My code snippet is

int nshash[10]={rrc_estab_raw__ns};
int nsflags[10]={CONFD_LOAD_SCHEMA_NODES};
maapi_load_schemas_list(maapi_socket,  CONFD_LOAD_SCHEMA_HASH, &nshash[0], &nsflags[0], 1);
object = dal_cs_node_cd(path);
rawn = dal_max_object_size(object);
ret1 = dal_db_get_object(.......);
if (rawn == ret1)
        for(cur = object->p_children, l = 0; cur != NULL; cur = dal_next_object_node(object, cur, &v[l]), l++)
                   tmpName = confd_hash2str(cur->tag);
                   printf("%s", tmpName);//confd_hash2str(cur->tag));

Try something like this:

u_int32_t nslist[1] = { rrc_estab_raw__ns };
int nsflags[1] = {CONFD_LOAD_SCHEMA_NODES};
if((maapi_load_schemas_list(msock, CONFD_LOAD_SCHEMA_HASH, nslist, nsflags, 1)) != CONFD_OK)
  printf ("error: %s (%d): %s\n", confd_strerror(confd_errno), confd_errno, confd_lasterr());
for (cur = object->children, l = 0; cur != NULL; cur = confd_next_object_node(object, cur, &v[l]), l++)
                   tmpName = confd_hash2str(cur->tag);
                   printf("%s", tmpName);

Hi cohult
I got the problem and its very strange.
If i do above handling in a separate thread facing problem. But if dont create thread and do it in main no problem is getting observed.

Note that if you are using the same socket for communication with ConfD from both threads, a request sent from one thread may get a reply to request sent from the other thread.

If you are using two threads and share a Linux socket between them, you need to synchronize between them so that a mixup of replies to requests does not occur. Best practice should be to keep it simple and use one socket per thread to avoid this type of issue.

Also, for the specific case of loading the schema information, it populates global data (i.e. available to all threads) in the library, so it is completely pointless and just a waste of resources to do it for each thread.