I am using (<http://linux.die.net/man/3/hsearch>) in my source code. I wrote a very basic code to test the hash functionality (did not want to reinvent the wheel by writing my own hash implementation). I see that it crashes with a segmentation fault in the search routine.

Any idea why its crashing?

```
 #include <stdio.h>
 #include <search.h>
 #include <stdlib.h>

 char *data[] = {
 "cpe1","cpe2","cpe3","cpe4","cpe5","cpe6","cpe7","cpe8","cpe9","cpe10","cpe11","cpe12","cpe13"};

int main()
{
ENTRY ep, ep1, *ep_ptr, ep2;
int loop;
char *ptr;
char input[100];

hcreate (30);

for (loop=0; loop<13;loop++)
{
    ptr = malloc (100);
    sprintf (ptr, "%d.%d.%d.%d%c", loop+1, loop*2, loop*3, loop, '\0');

    ep.key = data[loop];
    ep.data = (void *) ptr;

    printf ("%s --> %s\n", ep.key, (char *) ep.data);

    ep_ptr = hsearch(ep, ENTER);
}

ep2.data = (void *) "cpe1";
ep_ptr = hsearch(ep2, FIND);

printf("%9.9s -> %9.9s: %s\n", ep2.key,
       ep_ptr ? ep_ptr->key : "NULL", ep_ptr ? (char *)(ep_ptr->data) : "NULL");

return 0; 
}

```

OUtput:

```
 (gdb) r
 Starting program: /home/globus/code/cpe/a.out 
 warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
 cpe1 --> 1.0.0.0
 cpe2 --> 2.2.3.1
 cpe3 --> 3.4.6.2
 cpe4 --> 4.6.9.3
 cpe5 --> 5.8.12.4
 cpe6 --> 6.10.15.5
 cpe7 --> 7.12.18.6
 cpe8 --> 8.14.21.7
 cpe9 --> 9.16.24.8
  cpe10 --> 10.18.27.9
 cpe11 --> 11.20.30.10
 cpe12 --> 12.22.33.11
 cpe13 --> 13.24.36.12

  Program received signal SIGSEGV, Segmentation fault.
  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:32
  32    ../sysdeps/x86_64/multiarch/../strlen.S: No such file or directory.
 (gdb) bt
 #0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:32
 #1  0x00007ffff7b0ba71 in __GI_hsearch_r (item=..., action=FIND, retval=0x7fffffffdfd8, 
     htab=0x7ffff7dd67d0) at hsearch_r.c:149
 #2  0x00007ffff7b0b92e in hsearch (item=..., action=<optimized out>)
  at hsearch.c:34
 #3  0x00000000004007a0 in main () at hash_test.c:32
 (gdb) 

```