-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
I'm trying to run the function below, which is similar to test_lookup_linx() in basic.c:
static int
test_load_random(void)
{
struct poptrie *poptrie;
int prefix[4];
int prefixlen;
int nexthop[4];
int ret;
u32 addr1;
u32 addr2;
srand(time(NULL));
/* Initialize */
poptrie = poptrie_init(NULL, 19, 22);
if ( NULL == poptrie ) {
return -1;
}
/* Load some random routes */
for (size_t i = 0; i < 622607; i++) {
prefix[0] = rand() % 256;
prefix[1] = rand() % 256;
prefix[2] = rand() % 256;
prefix[3] = rand() % 256;
prefixlen = rand() % 33;
nexthop[0] = rand() % 256;
nexthop[1] = rand() % 256;
nexthop[2] = rand() % 256;
nexthop[3] = rand() % 256;
/* Convert to u32 */
addr1 = ((u32)prefix[0] << 24) + ((u32)prefix[1] << 16)
+ ((u32)prefix[2] << 8) + (u32)prefix[3];
addr2 = ((u32)nexthop[0] << 24) + ((u32)nexthop[1] << 16)
+ ((u32)nexthop[2] << 8) + (u32)nexthop[3];
/* Add an entry */
ret = poptrie_route_update(poptrie, addr1, prefixlen, (void *)(u64)addr2);
if ( ret != 0 ) {
return -1;
}
/* Test progress */
printf(".");
fflush(stdout);
}
/* Release */
poptrie_release(poptrie);
return 0;
}
int
main()
{
test_load_random();
return 0;
}However, I'm getting segfaults after updating/adding some routes as below:
[alexandrelucchesi@phi poptrie]$ ./a.out | wc -m
2529
[alexandrelucchesi@phi poptrie]$ ./a.out | wc -m
2491
[alexandrelucchesi@phi poptrie]$ ./a.out | wc -m
2547
[alexandrelucchesi@phi poptrie]$ ./a.out | wc -m
2535
[alexandrelucchesi@phi poptrie]$ ./a.out | wc -m
2510I've tried to compile the poptrie library and my code using both icc and gcc, but I've got the same results either way.
Could you please give some directions?
Metadata
Metadata
Assignees
Labels
No labels